@authoric/js 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +94 -3
- package/bin/authoric.mjs +345 -0
- package/dist/cjs/app-actions.js +40 -0
- package/dist/cjs/app-actions.js.map +1 -0
- package/dist/cjs/auth.js +335 -0
- package/dist/cjs/auth.js.map +1 -0
- package/dist/cjs/client.js +121 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/cookies.js +137 -0
- package/dist/cjs/cookies.js.map +1 -0
- package/dist/cjs/data.js +197 -0
- package/dist/cjs/data.js.map +1 -0
- package/dist/cjs/errors.js +70 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/files.js +188 -0
- package/dist/cjs/files.js.map +1 -0
- package/dist/cjs/generated/error-codes.js +435 -0
- package/dist/cjs/generated/error-codes.js.map +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/realtime.js +191 -0
- package/dist/cjs/realtime.js.map +1 -0
- package/dist/cjs/routes.js +113 -0
- package/dist/cjs/routes.js.map +1 -0
- package/dist/cjs/session.js +430 -0
- package/dist/cjs/session.js.map +1 -0
- package/dist/cjs/storage-adapters.js +83 -0
- package/dist/cjs/storage-adapters.js.map +1 -0
- package/dist/cjs/teams.js +152 -0
- package/dist/cjs/teams.js.map +1 -0
- package/dist/cjs/transport.js +189 -0
- package/dist/cjs/transport.js.map +1 -0
- package/dist/cjs/types.js +7 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/app-actions.d.ts +32 -0
- package/dist/esm/app-actions.d.ts.map +1 -0
- package/dist/esm/app-actions.js +37 -0
- package/dist/esm/app-actions.js.map +1 -0
- package/dist/esm/auth.d.ts +259 -0
- package/dist/esm/auth.d.ts.map +1 -0
- package/dist/esm/auth.js +331 -0
- package/dist/esm/auth.js.map +1 -0
- package/dist/esm/client.d.ts +82 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +115 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/cookies.d.ts +66 -0
- package/dist/esm/cookies.d.ts.map +1 -0
- package/dist/esm/cookies.js +129 -0
- package/dist/esm/cookies.js.map +1 -0
- package/dist/esm/data.d.ts +211 -0
- package/dist/esm/data.d.ts.map +1 -0
- package/dist/esm/data.js +191 -0
- package/dist/esm/data.js.map +1 -0
- package/dist/esm/errors.d.ts +61 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +63 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/files.d.ts +76 -0
- package/dist/esm/files.d.ts.map +1 -0
- package/dist/esm/files.js +184 -0
- package/dist/esm/files.js.map +1 -0
- package/dist/esm/generated/error-codes.d.ts +5 -0
- package/dist/esm/generated/error-codes.d.ts.map +1 -0
- package/dist/esm/generated/error-codes.js +432 -0
- package/dist/esm/generated/error-codes.js.map +1 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/realtime.d.ts +33 -0
- package/dist/esm/realtime.d.ts.map +1 -0
- package/dist/esm/realtime.js +186 -0
- package/dist/esm/realtime.js.map +1 -0
- package/dist/esm/routes.d.ts +75 -0
- package/dist/esm/routes.d.ts.map +1 -0
- package/dist/esm/routes.js +108 -0
- package/dist/esm/routes.js.map +1 -0
- package/dist/esm/session.d.ts +99 -0
- package/dist/esm/session.d.ts.map +1 -0
- package/dist/esm/session.js +425 -0
- package/dist/esm/session.js.map +1 -0
- package/dist/esm/storage-adapters.d.ts +31 -0
- package/dist/esm/storage-adapters.d.ts.map +1 -0
- package/dist/esm/storage-adapters.js +76 -0
- package/dist/esm/storage-adapters.js.map +1 -0
- package/dist/esm/teams.d.ts +157 -0
- package/dist/esm/teams.d.ts.map +1 -0
- package/dist/esm/teams.js +146 -0
- package/dist/esm/teams.js.map +1 -0
- package/dist/esm/transport.d.ts +56 -0
- package/dist/esm/transport.d.ts.map +1 -0
- package/dist/esm/transport.js +185 -0
- package/dist/esm/transport.js.map +1 -0
- package/dist/esm/types.d.ts +203 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +6 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +54 -6
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { SessionManager } from "./session.js";
|
|
2
|
+
import type { Transport } from "./transport.js";
|
|
3
|
+
import type { Session } from "./types.js";
|
|
4
|
+
type Json = Record<string, unknown>;
|
|
5
|
+
export interface OrgSummary {
|
|
6
|
+
uid: string;
|
|
7
|
+
name: string;
|
|
8
|
+
slug?: string;
|
|
9
|
+
isActive?: boolean;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface Invitation {
|
|
13
|
+
uid: string;
|
|
14
|
+
status: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** The user's organizations: theirs, the ones they joined, and the active one's people. */
|
|
18
|
+
export declare class OrgsClient {
|
|
19
|
+
private readonly transport;
|
|
20
|
+
private readonly session;
|
|
21
|
+
constructor(transport: Transport, session: SessionManager);
|
|
22
|
+
/** Every org the user belongs to, the active one flagged. */
|
|
23
|
+
list(): Promise<Json>;
|
|
24
|
+
/** Act in another of the user's orgs (the same as `auth.switchOrg`). */
|
|
25
|
+
switch(orgUid: string): Promise<Session>;
|
|
26
|
+
/**
|
|
27
|
+
* Create an organization beyond the user's own, which they then own. Only where the app's owner
|
|
28
|
+
* allows it (`ORG_CREATION_DISABLED` otherwise), up to its limit (`ORG_LIMIT_REACHED`).
|
|
29
|
+
*/
|
|
30
|
+
create(input: {
|
|
31
|
+
name: string;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
created: true;
|
|
34
|
+
org: {
|
|
35
|
+
uid: string;
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/** Rename the active org. */
|
|
40
|
+
rename(input: {
|
|
41
|
+
name: string;
|
|
42
|
+
}): Promise<Json>;
|
|
43
|
+
/** The active org's members. */
|
|
44
|
+
readonly members: {
|
|
45
|
+
list: (input?: {
|
|
46
|
+
status?: string;
|
|
47
|
+
}) => Promise<Json>;
|
|
48
|
+
/** Remove someone else from the active org. */
|
|
49
|
+
remove: (input: {
|
|
50
|
+
membershipUid: string;
|
|
51
|
+
}) => Promise<Json>;
|
|
52
|
+
/** Leave the active org (not the user's own). */
|
|
53
|
+
leave: () => Promise<Json>;
|
|
54
|
+
};
|
|
55
|
+
/** Invitations into the active org, and the ones addressed to the user. */
|
|
56
|
+
readonly invitations: {
|
|
57
|
+
/** Invite someone to the active org by email. The app sends them its invitation email. */
|
|
58
|
+
send: (input: {
|
|
59
|
+
inviteeEmail: string;
|
|
60
|
+
expiresInDays?: number;
|
|
61
|
+
}) => Promise<Json>;
|
|
62
|
+
sent: (input?: {
|
|
63
|
+
status?: string;
|
|
64
|
+
}) => Promise<Json>;
|
|
65
|
+
received: (input?: {
|
|
66
|
+
status?: string;
|
|
67
|
+
}) => Promise<Json>;
|
|
68
|
+
accept: (input: {
|
|
69
|
+
invitationUid: string;
|
|
70
|
+
}) => Promise<Json>;
|
|
71
|
+
deny: (input: {
|
|
72
|
+
invitationUid: string;
|
|
73
|
+
}) => Promise<Json>;
|
|
74
|
+
/** Withdraw an invitation addressed to the user. */
|
|
75
|
+
cancel: (input: {
|
|
76
|
+
invitationUid: string;
|
|
77
|
+
}) => Promise<Json>;
|
|
78
|
+
/** Withdraw an invitation the active org sent. */
|
|
79
|
+
revoke: (input: {
|
|
80
|
+
invitationUid: string;
|
|
81
|
+
}) => Promise<Json>;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
type RoleTarget = {
|
|
85
|
+
userUid: string;
|
|
86
|
+
orgUid?: string;
|
|
87
|
+
} & ({
|
|
88
|
+
roleUid: string;
|
|
89
|
+
roleKey?: undefined;
|
|
90
|
+
} | {
|
|
91
|
+
roleKey: string;
|
|
92
|
+
roleUid?: undefined;
|
|
93
|
+
});
|
|
94
|
+
/** Roles in the user's org: what exists, who holds what, and granting within what the caller holds. */
|
|
95
|
+
export declare class RolesClient {
|
|
96
|
+
private readonly transport;
|
|
97
|
+
constructor(transport: Transport);
|
|
98
|
+
/** The roles of the active org. */
|
|
99
|
+
list(input?: {
|
|
100
|
+
limit?: number;
|
|
101
|
+
offset?: number;
|
|
102
|
+
}): Promise<Json>;
|
|
103
|
+
/** The roles one user holds. */
|
|
104
|
+
forUser(userUid: string): Promise<Json>;
|
|
105
|
+
private change;
|
|
106
|
+
/** Give a user a role. The server refuses a role carrying more than the caller holds. */
|
|
107
|
+
assign(target: RoleTarget): Promise<Json>;
|
|
108
|
+
/** Take a role away from a user. */
|
|
109
|
+
unassign(target: RoleTarget): Promise<Json>;
|
|
110
|
+
}
|
|
111
|
+
export interface CatalogPrice {
|
|
112
|
+
id: string;
|
|
113
|
+
unitAmount: number | null;
|
|
114
|
+
currency: string | null;
|
|
115
|
+
interval: string | null;
|
|
116
|
+
recurring: boolean;
|
|
117
|
+
nickname: string | null;
|
|
118
|
+
}
|
|
119
|
+
export interface Catalog {
|
|
120
|
+
mode: "test" | "live";
|
|
121
|
+
/** The connected Stripe account's publishable key, for Stripe's own payment form. Public by design. */
|
|
122
|
+
publishableKey: string | null;
|
|
123
|
+
products: Array<{
|
|
124
|
+
uid: string;
|
|
125
|
+
name: string;
|
|
126
|
+
description: string | null;
|
|
127
|
+
display: Record<string, unknown>;
|
|
128
|
+
defaultPriceId: string | null;
|
|
129
|
+
prices: CatalogPrice[];
|
|
130
|
+
}>;
|
|
131
|
+
}
|
|
132
|
+
/** Buying the app's products, through the app owner's own Stripe account. */
|
|
133
|
+
export declare class BillingClient {
|
|
134
|
+
private readonly transport;
|
|
135
|
+
constructor(transport: Transport);
|
|
136
|
+
/** The app's active products and prices, for a pricing page. Works signed out. */
|
|
137
|
+
catalog(): Promise<Catalog>;
|
|
138
|
+
/** Start a subscription to a recurring price. Answers the client secret Stripe's payment form confirms. */
|
|
139
|
+
subscribe(input: {
|
|
140
|
+
priceId: string;
|
|
141
|
+
}): Promise<Json>;
|
|
142
|
+
/** A one-time purchase. Answers the client secret Stripe's payment form confirms. */
|
|
143
|
+
order(input: {
|
|
144
|
+
priceId: string;
|
|
145
|
+
quantity?: number;
|
|
146
|
+
}): Promise<Json>;
|
|
147
|
+
/** The user's subscriptions. */
|
|
148
|
+
subscriptions(): Promise<Json>;
|
|
149
|
+
/** Cancel at the end of the period. */
|
|
150
|
+
cancel(subscriptionUid: string): Promise<Json>;
|
|
151
|
+
/** Undo a pending cancellation. */
|
|
152
|
+
resume(subscriptionUid: string): Promise<Json>;
|
|
153
|
+
/** What the user's purchases entitle them to (limits and features). */
|
|
154
|
+
entitlements(): Promise<Json>;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=teams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../../src/teams.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAyBpC,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAA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B,uGAAuG;IACvG,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,MAAM,EAAE,YAAY,EAAE,CAAC;KACvB,CAAC,CAAC;CACH;AAED,6EAA6E;AAC7E,qBAAa,aAAa;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD,kFAAkF;IAClF,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3B,2GAA2G;IAC3G,SAAS,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,qFAAqF;IACrF,KAAK,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE,gCAAgC;IAChC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,uCAAuC;IACvC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,mCAAmC;IACnC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,uEAAuE;IACvE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Teams, roles and billing (notes/client-sdk-plan.md §2.4): typed methods over the API's seeded
|
|
2
|
+
// actions (./app-actions.ts). The server decides everything, as always: who may invite, the role
|
|
3
|
+
// ceiling ("you may only grant what you hold"), what a user may buy. The SDK adds no rule of its own.
|
|
4
|
+
import { clientError } from "./errors.js";
|
|
5
|
+
import { APP_ACTIONS } from "./app-actions.js";
|
|
6
|
+
import { fillPath, ROUTES } from "./routes.js";
|
|
7
|
+
const call = (transport, name, options = {}) => {
|
|
8
|
+
const spec = APP_ACTIONS[name];
|
|
9
|
+
for (const [key, value] of Object.entries(options.params ?? {})) {
|
|
10
|
+
if (typeof value !== "string" || !value)
|
|
11
|
+
throw clientError("AUTHORIC_INVALID_ARGUMENT", `Missing ${key}.`);
|
|
12
|
+
}
|
|
13
|
+
// The table and the action's own path are constants from APP_ACTIONS; every caller-supplied value
|
|
14
|
+
// goes through fillPath, which encodes it as exactly ONE segment (a "/" cannot add one, ".." is
|
|
15
|
+
// refused), so no value can steer the request to another action.
|
|
16
|
+
const route = {
|
|
17
|
+
method: spec.method,
|
|
18
|
+
path: `${fillPath("/autocrud/:table", { table: spec.table })}${fillPath(spec.path, options.params ?? {})}`,
|
|
19
|
+
};
|
|
20
|
+
return transport.request(route, {
|
|
21
|
+
body: spec.method === "GET" ? undefined : (options.body ?? {}),
|
|
22
|
+
query: options.query,
|
|
23
|
+
auth: options.anonymous ? "optional" : "required",
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
/** The user's organizations: theirs, the ones they joined, and the active one's people. */
|
|
27
|
+
export class OrgsClient {
|
|
28
|
+
constructor(transport, session) {
|
|
29
|
+
this.transport = transport;
|
|
30
|
+
this.session = session;
|
|
31
|
+
/** The active org's members. */
|
|
32
|
+
this.members = {
|
|
33
|
+
list: (input = {}) => call(this.transport, "members", { query: input }),
|
|
34
|
+
/** Remove someone else from the active org. */
|
|
35
|
+
remove: (input) => call(this.transport, "removeMember", { body: input }),
|
|
36
|
+
/** Leave the active org (not the user's own). */
|
|
37
|
+
leave: () => call(this.transport, "leaveOrg"),
|
|
38
|
+
};
|
|
39
|
+
/** Invitations into the active org, and the ones addressed to the user. */
|
|
40
|
+
this.invitations = {
|
|
41
|
+
/** Invite someone to the active org by email. The app sends them its invitation email. */
|
|
42
|
+
send: (input) => call(this.transport, "invite", { body: input }),
|
|
43
|
+
sent: (input = {}) => call(this.transport, "invitesSent", { query: input }),
|
|
44
|
+
received: (input = {}) => call(this.transport, "invitesReceived", { query: input }),
|
|
45
|
+
accept: (input) => call(this.transport, "inviteAccept", { body: input }),
|
|
46
|
+
deny: (input) => call(this.transport, "inviteDeny", { body: input }),
|
|
47
|
+
/** Withdraw an invitation addressed to the user. */
|
|
48
|
+
cancel: (input) => call(this.transport, "inviteCancel", { body: input }),
|
|
49
|
+
/** Withdraw an invitation the active org sent. */
|
|
50
|
+
revoke: (input) => call(this.transport, "inviteRevoke", { body: input }),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Every org the user belongs to, the active one flagged. */
|
|
54
|
+
list() {
|
|
55
|
+
return call(this.transport, "myOrgs");
|
|
56
|
+
}
|
|
57
|
+
/** Act in another of the user's orgs (the same as `auth.switchOrg`). */
|
|
58
|
+
async switch(orgUid) {
|
|
59
|
+
if (!orgUid)
|
|
60
|
+
throw clientError("AUTHORIC_INVALID_ARGUMENT", "switch needs the org's uid.");
|
|
61
|
+
const session = await this.session.refresh({ activeOrgUid: orgUid });
|
|
62
|
+
if (!session)
|
|
63
|
+
throw clientError("AUTHORIC_NOT_SIGNED_IN", "Sign in first.");
|
|
64
|
+
return session;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create an organization beyond the user's own, which they then own. Only where the app's owner
|
|
68
|
+
* allows it (`ORG_CREATION_DISABLED` otherwise), up to its limit (`ORG_LIMIT_REACHED`).
|
|
69
|
+
*/
|
|
70
|
+
create(input) {
|
|
71
|
+
return call(this.transport, "createOrg", { body: input });
|
|
72
|
+
}
|
|
73
|
+
/** Rename the active org. */
|
|
74
|
+
rename(input) {
|
|
75
|
+
return call(this.transport, "renameOrg", { body: input });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Roles in the user's org: what exists, who holds what, and granting within what the caller holds. */
|
|
79
|
+
export class RolesClient {
|
|
80
|
+
constructor(transport) {
|
|
81
|
+
this.transport = transport;
|
|
82
|
+
}
|
|
83
|
+
/** The roles of the active org. */
|
|
84
|
+
list(input = {}) {
|
|
85
|
+
return this.transport.request(ROUTES.rowsList, { params: { table: "roles" }, query: input });
|
|
86
|
+
}
|
|
87
|
+
/** The roles one user holds. */
|
|
88
|
+
forUser(userUid) {
|
|
89
|
+
return call(this.transport, "userRoles", { params: { userUid } });
|
|
90
|
+
}
|
|
91
|
+
async change(name, target) {
|
|
92
|
+
const body = {
|
|
93
|
+
user_uid: target.userUid,
|
|
94
|
+
...(target.roleUid ? { role_uid: target.roleUid } : { role_key: target.roleKey }),
|
|
95
|
+
...(target.orgUid ? { target_org_uid: target.orgUid } : {}),
|
|
96
|
+
};
|
|
97
|
+
// The server answers a review first (what changes, and a hash of it), then applies exactly that.
|
|
98
|
+
const review = await call(this.transport, name, { body: { ...body, mode: "review" } });
|
|
99
|
+
if (!review?.reviewHash)
|
|
100
|
+
throw clientError("AUTHORIC_BAD_RESPONSE", "The role change answered no review.");
|
|
101
|
+
return call(this.transport, name, { body: { ...body, mode: "confirm", reviewHash: review.reviewHash } });
|
|
102
|
+
}
|
|
103
|
+
/** Give a user a role. The server refuses a role carrying more than the caller holds. */
|
|
104
|
+
assign(target) {
|
|
105
|
+
return this.change("bindRole", target);
|
|
106
|
+
}
|
|
107
|
+
/** Take a role away from a user. */
|
|
108
|
+
unassign(target) {
|
|
109
|
+
return this.change("unbindRole", target);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Buying the app's products, through the app owner's own Stripe account. */
|
|
113
|
+
export class BillingClient {
|
|
114
|
+
constructor(transport) {
|
|
115
|
+
this.transport = transport;
|
|
116
|
+
}
|
|
117
|
+
/** The app's active products and prices, for a pricing page. Works signed out. */
|
|
118
|
+
catalog() {
|
|
119
|
+
return call(this.transport, "catalog", { anonymous: true });
|
|
120
|
+
}
|
|
121
|
+
/** Start a subscription to a recurring price. Answers the client secret Stripe's payment form confirms. */
|
|
122
|
+
subscribe(input) {
|
|
123
|
+
return call(this.transport, "subscribe", { body: input });
|
|
124
|
+
}
|
|
125
|
+
/** A one-time purchase. Answers the client secret Stripe's payment form confirms. */
|
|
126
|
+
order(input) {
|
|
127
|
+
return call(this.transport, "order", { body: input });
|
|
128
|
+
}
|
|
129
|
+
/** The user's subscriptions. */
|
|
130
|
+
subscriptions() {
|
|
131
|
+
return call(this.transport, "subscriptions");
|
|
132
|
+
}
|
|
133
|
+
/** Cancel at the end of the period. */
|
|
134
|
+
cancel(subscriptionUid) {
|
|
135
|
+
return call(this.transport, "cancelSubscription", { params: { subscriptionUid } });
|
|
136
|
+
}
|
|
137
|
+
/** Undo a pending cancellation. */
|
|
138
|
+
resume(subscriptionUid) {
|
|
139
|
+
return call(this.transport, "resumeSubscription", { params: { subscriptionUid } });
|
|
140
|
+
}
|
|
141
|
+
/** What the user's purchases entitle them to (limits and features). */
|
|
142
|
+
entitlements() {
|
|
143
|
+
return call(this.transport, "entitlements");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../src/teams.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,iGAAiG;AACjG,sGAAsG;AACtG,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAO3D,MAAM,IAAI,GAAG,CACZ,SAAoB,EACpB,IAAmB,EACnB,UAAwH,EAAE,EAC7G,EAAE;IACf,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO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AAT,SAAS,CAAW;IAAG,CAAC;IAErD,kFAAkF;IAClF,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,2GAA2G;IAC3G,SAAS,CAAC,KAA0B;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,KAA6C;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,gCAAgC;IAChC,aAAa;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IAC9C,CAAC;IAED,uCAAuC;IACvC,MAAM,CAAC,eAAuB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,EAAE,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,mCAAmC;IACnC,MAAM,CAAC,eAAuB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,EAAE,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,uEAAuE;IACvE,YAAY;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;CACD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Route } from "./routes.js";
|
|
2
|
+
import type { Session } from "./types.js";
|
|
3
|
+
export interface TokenSource {
|
|
4
|
+
getAccessToken(): Promise<string | null>;
|
|
5
|
+
refresh(options: {
|
|
6
|
+
force?: boolean;
|
|
7
|
+
}): Promise<Session | null>;
|
|
8
|
+
end(reason?: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface DebugEvent {
|
|
11
|
+
method: string;
|
|
12
|
+
/** The route's TEMPLATE (`/autocrud/:table/:rowUid`), never the filled path or its query. */
|
|
13
|
+
route: string;
|
|
14
|
+
status: number | null;
|
|
15
|
+
code: string | null;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
requestId: string | null;
|
|
18
|
+
attempt: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TransportConfig {
|
|
21
|
+
baseUrl: string;
|
|
22
|
+
appUid: string;
|
|
23
|
+
fetch: typeof fetch;
|
|
24
|
+
/** The longest the SDK waits on a Retry-After before giving up and throwing. */
|
|
25
|
+
maxRetryWaitMs: number;
|
|
26
|
+
debug: ((event: DebugEvent) => void) | null;
|
|
27
|
+
}
|
|
28
|
+
export type QueryValue = string | number | boolean | null | undefined;
|
|
29
|
+
export interface RequestOptions {
|
|
30
|
+
params?: Record<string, string>;
|
|
31
|
+
query?: Record<string, QueryValue>;
|
|
32
|
+
/** A JSON body. */
|
|
33
|
+
body?: unknown;
|
|
34
|
+
/** A multipart body (uploads). Content-Type is left to fetch. */
|
|
35
|
+
formData?: FormData;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
/** "required" (the default) needs a signed-in user; "optional" sends a token when there is one; "none" never does. */
|
|
38
|
+
auth?: "required" | "optional" | "none";
|
|
39
|
+
idempotencyKey?: string;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
/** "json" (default), "blob", "arrayBuffer", or "response" for the raw Response (a stream). */
|
|
42
|
+
responseType?: "json" | "blob" | "arrayBuffer" | "response";
|
|
43
|
+
accept?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare class Transport {
|
|
46
|
+
private readonly config;
|
|
47
|
+
private tokens;
|
|
48
|
+
constructor(config: TransportConfig);
|
|
49
|
+
setTokenSource(tokens: TokenSource): void;
|
|
50
|
+
/** The absolute URL of an app route. */
|
|
51
|
+
url(route: Route, params?: Record<string, string>, query?: Record<string, QueryValue>): string;
|
|
52
|
+
request<T = unknown>(route: Route, options?: RequestOptions): Promise<T>;
|
|
53
|
+
private read;
|
|
54
|
+
private log;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAWA,OAAO,EAAY,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,WAAW;IAC3B,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,OAAO,CAAC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC/D,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,6FAA6F;IAC7F,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5C;A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
1
|
+
// Every request the SDK makes goes through here. One place builds the URL, attaches the user's token,
|
|
2
|
+
// refreshes it once when the server says it expired, honors Retry-After, and turns a refusal into an
|
|
3
|
+
// AuthoricError.
|
|
4
|
+
//
|
|
5
|
+
// What it never does (notes/client-sdk-plan.md, "Things the SDK must never do"):
|
|
6
|
+
// - send the Authorization header anywhere but the configured API (a presigned PUT, a file link and
|
|
7
|
+
// an OAuth redirect are fetched by their callers without it);
|
|
8
|
+
// - retry a write that carries no Idempotency-Key;
|
|
9
|
+
// - retry after SESSION_ENDED, or after any 4xx other than one refresh on an expired token;
|
|
10
|
+
// - log a header, a body, a token or a query value.
|
|
11
|
+
import { AuthoricError, clientError, errorFromResponse } from "./errors.js";
|
|
12
|
+
import { fillPath } from "./routes.js";
|
|
13
|
+
const WAIT_CODES = new Set(["APP_WAKING", "APP_RESTORING", "RATE_LIMITED"]);
|
|
14
|
+
const parseRetryAfter = (value, now = Date.now()) => {
|
|
15
|
+
if (!value)
|
|
16
|
+
return null;
|
|
17
|
+
const seconds = Number(value);
|
|
18
|
+
if (Number.isFinite(seconds) && seconds >= 0)
|
|
19
|
+
return seconds;
|
|
20
|
+
const at = Date.parse(value);
|
|
21
|
+
return Number.isFinite(at) ? Math.max(0, Math.ceil((at - now) / 1000)) : null;
|
|
22
|
+
};
|
|
23
|
+
const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
24
|
+
if (signal?.aborted) {
|
|
25
|
+
reject(signal.reason ?? new Error("Aborted"));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const timer = setTimeout(() => {
|
|
29
|
+
signal?.removeEventListener("abort", onAbort);
|
|
30
|
+
resolve();
|
|
31
|
+
}, ms);
|
|
32
|
+
const onAbort = () => {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
reject(signal?.reason ?? new Error("Aborted"));
|
|
35
|
+
};
|
|
36
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
37
|
+
});
|
|
38
|
+
const isAbort = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
39
|
+
export class Transport {
|
|
40
|
+
constructor(config) {
|
|
41
|
+
this.tokens = null;
|
|
42
|
+
this.config = config;
|
|
43
|
+
}
|
|
44
|
+
setTokenSource(tokens) {
|
|
45
|
+
this.tokens = tokens;
|
|
46
|
+
}
|
|
47
|
+
/** The absolute URL of an app route. */
|
|
48
|
+
url(route, params, query) {
|
|
49
|
+
const search = new URLSearchParams();
|
|
50
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
51
|
+
if (value === undefined || value === null)
|
|
52
|
+
continue;
|
|
53
|
+
search.append(key, String(value));
|
|
54
|
+
}
|
|
55
|
+
const qs = search.toString();
|
|
56
|
+
return `${this.config.baseUrl}/${encodeURIComponent(this.config.appUid)}${fillPath(route.path, params)}${qs ? `?${qs}` : ""}`;
|
|
57
|
+
}
|
|
58
|
+
async request(route, options = {}) {
|
|
59
|
+
const auth = options.auth ?? "required";
|
|
60
|
+
const method = route.method;
|
|
61
|
+
// Safe to send twice: a read, or a write the server will recognize by its key.
|
|
62
|
+
const retrySafe = method === "GET" || Boolean(options.idempotencyKey);
|
|
63
|
+
const url = this.url(route, options.params, options.query);
|
|
64
|
+
let refreshed = false;
|
|
65
|
+
let waited = false;
|
|
66
|
+
for (let attempt = 1;; attempt += 1) {
|
|
67
|
+
const headers = {
|
|
68
|
+
Accept: options.accept ?? "application/json",
|
|
69
|
+
...(options.headers ?? {}),
|
|
70
|
+
};
|
|
71
|
+
let body;
|
|
72
|
+
if (options.formData) {
|
|
73
|
+
body = options.formData;
|
|
74
|
+
}
|
|
75
|
+
else if (options.body !== undefined) {
|
|
76
|
+
headers["Content-Type"] = "application/json";
|
|
77
|
+
body = JSON.stringify(options.body);
|
|
78
|
+
}
|
|
79
|
+
if (options.idempotencyKey)
|
|
80
|
+
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
81
|
+
let token = null;
|
|
82
|
+
if (auth !== "none") {
|
|
83
|
+
token = this.tokens ? await this.tokens.getAccessToken() : null;
|
|
84
|
+
if (!token && auth === "required") {
|
|
85
|
+
throw clientError("AUTHORIC_NOT_SIGNED_IN", "Sign in first: this call acts as a signed-in user.");
|
|
86
|
+
}
|
|
87
|
+
if (token)
|
|
88
|
+
headers.Authorization = `Bearer ${token}`;
|
|
89
|
+
}
|
|
90
|
+
const started = Date.now();
|
|
91
|
+
let response;
|
|
92
|
+
try {
|
|
93
|
+
response = await this.config.fetch(url, {
|
|
94
|
+
method,
|
|
95
|
+
headers,
|
|
96
|
+
body,
|
|
97
|
+
signal: options.signal,
|
|
98
|
+
// Never ambient credentials: the API authenticates by bearer token alone.
|
|
99
|
+
credentials: "omit",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (isAbort(error) || options.signal?.aborted)
|
|
104
|
+
throw error;
|
|
105
|
+
this.log({ method, route: route.path, status: null, code: null, durationMs: Date.now() - started, requestId: null, attempt });
|
|
106
|
+
throw clientError("AUTHORIC_NETWORK_ERROR", "The request did not reach Authoric (offline, or blocked).", error);
|
|
107
|
+
}
|
|
108
|
+
if (response.ok) {
|
|
109
|
+
this.log({ method, route: route.path, status: response.status, code: null, durationMs: Date.now() - started, requestId: null, attempt });
|
|
110
|
+
return (await this.read(response, options.responseType ?? "json"));
|
|
111
|
+
}
|
|
112
|
+
const errorBody = await response
|
|
113
|
+
.clone()
|
|
114
|
+
.json()
|
|
115
|
+
.catch(() => null);
|
|
116
|
+
const retryAfter = parseRetryAfter(response.headers.get("Retry-After"));
|
|
117
|
+
const error = errorFromResponse(response.status, errorBody, retryAfter);
|
|
118
|
+
this.log({ method, route: route.path, status: response.status, code: error.code, durationMs: Date.now() - started, requestId: error.requestId, attempt });
|
|
119
|
+
// An expired access token: refresh ONCE, then send the same request again.
|
|
120
|
+
if (response.status === 401 &&
|
|
121
|
+
token &&
|
|
122
|
+
!refreshed &&
|
|
123
|
+
this.tokens &&
|
|
124
|
+
(error.code === "AUTH_TOKEN_EXPIRED" || error.code === "AUTH_TOKEN_INVALID")) {
|
|
125
|
+
refreshed = true;
|
|
126
|
+
const session = await this.tokens.refresh({ force: true });
|
|
127
|
+
if (session)
|
|
128
|
+
continue;
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
// The session is over on the server: forget it here too, and stop.
|
|
132
|
+
if (error.code === "SESSION_ENDED" && token && this.tokens) {
|
|
133
|
+
const reason = error.details?.reason;
|
|
134
|
+
await this.tokens.end(reason ?? "ended");
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
// The server asked for a wait: once, within the cap, and only when sending again is safe.
|
|
138
|
+
const waitSeconds = error.retryAfterSeconds;
|
|
139
|
+
if (!waited &&
|
|
140
|
+
retrySafe &&
|
|
141
|
+
waitSeconds != null &&
|
|
142
|
+
(WAIT_CODES.has(String(error.code)) || response.status === 429 || response.status === 503) &&
|
|
143
|
+
waitSeconds * 1000 <= this.config.maxRetryWaitMs) {
|
|
144
|
+
waited = true;
|
|
145
|
+
await sleep(waitSeconds * 1000, options.signal);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async read(response, type) {
|
|
152
|
+
if (type === "response")
|
|
153
|
+
return response;
|
|
154
|
+
if (type === "blob")
|
|
155
|
+
return response.blob();
|
|
156
|
+
if (type === "arrayBuffer")
|
|
157
|
+
return response.arrayBuffer();
|
|
158
|
+
if (response.status === 204)
|
|
159
|
+
return null;
|
|
160
|
+
const text = await response.text();
|
|
161
|
+
if (!text)
|
|
162
|
+
return null;
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(text);
|
|
165
|
+
}
|
|
166
|
+
catch (cause) {
|
|
167
|
+
throw new AuthoricError("The server answered with something that is not JSON.", {
|
|
168
|
+
code: "AUTHORIC_BAD_RESPONSE",
|
|
169
|
+
status: response.status,
|
|
170
|
+
cause,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
log(event) {
|
|
175
|
+
if (!this.config.debug)
|
|
176
|
+
return;
|
|
177
|
+
try {
|
|
178
|
+
this.config.debug(event);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// A logger's bug must not fail the request.
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,qGAAqG;AACrG,iBAAiB;AACjB,EAAE;AACF,iFAAiF;AACjF,sGAAsG;AACtG,kEAAkE;AAClE,qDAAqD;AACrD,8FAA8F;AAC9F,sDAAsD;AACtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAc,MAAM,aAAa,CAAC;AAgDnD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;AAE5E,MAAM,eAAe,GAAG,CAAC,KAAoB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAiB,EAAE;IACjF,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IAC7D,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,CA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