@agentjam/sdk 0.2.0 → 0.3.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/agent.d.ts +4 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +58 -32
- package/dist/agent.js.map +1 -1
- package/dist/anyOf.d.ts +66 -0
- package/dist/anyOf.d.ts.map +1 -0
- package/dist/anyOf.js +135 -0
- package/dist/anyOf.js.map +1 -0
- package/dist/chooser.d.ts +2 -0
- package/dist/chooser.d.ts.map +1 -0
- package/dist/chooser.js +187 -0
- package/dist/chooser.js.map +1 -0
- package/dist/connections.d.ts +41 -10
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +33 -9
- package/dist/connections.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/oauthCallbacks.js +14 -24
- package/dist/oauthCallbacks.js.map +1 -1
- package/dist/pages.d.ts +7 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +25 -0
- package/dist/pages.js.map +1 -0
- package/dist/platforms/discord.d.ts +74 -0
- package/dist/platforms/discord.d.ts.map +1 -0
- package/dist/platforms/discord.js +184 -0
- package/dist/platforms/discord.js.map +1 -0
- package/dist/platforms/discordGateway.d.ts +74 -0
- package/dist/platforms/discordGateway.d.ts.map +1 -0
- package/dist/platforms/discordGateway.js +377 -0
- package/dist/platforms/discordGateway.js.map +1 -0
- package/dist/platforms/google.d.ts.map +1 -1
- package/dist/platforms/google.js +11 -8
- package/dist/platforms/google.js.map +1 -1
- package/dist/platforms/microsoft.d.ts +145 -0
- package/dist/platforms/microsoft.d.ts.map +1 -0
- package/dist/platforms/microsoft.js +362 -0
- package/dist/platforms/microsoft.js.map +1 -0
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +13 -3
- package/dist/profile.js.map +1 -1
- package/dist/protocol.d.ts +13 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/providers.d.ts +9 -2
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +7 -0
- package/dist/providers.js.map +1 -1
- package/dist/relay/credentials.d.ts.map +1 -1
- package/dist/relay/credentials.js +13 -1
- package/dist/relay/credentials.js.map +1 -1
- package/dist/relay/grants.d.ts +33 -4
- package/dist/relay/grants.d.ts.map +1 -1
- package/dist/relay/memory.d.ts +13 -1
- package/dist/relay/memory.d.ts.map +1 -1
- package/dist/relay/memory.js +46 -2
- package/dist/relay/memory.js.map +1 -1
- package/dist/relay/schedules.d.ts +11 -0
- package/dist/relay/schedules.d.ts.map +1 -1
- package/dist/relay/schedules.js +23 -2
- package/dist/relay/schedules.js.map +1 -1
- package/dist/tasks/incoming.d.ts +11 -0
- package/dist/tasks/incoming.d.ts.map +1 -1
- package/dist/tasks/incoming.js.map +1 -1
- package/dist/types.d.ts +16 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/vaults/local.d.ts +26 -17
- package/dist/vaults/local.d.ts.map +1 -1
- package/dist/vaults/local.js +218 -107
- package/dist/vaults/local.js.map +1 -1
- package/dist/vaults/remote.d.ts +15 -17
- package/dist/vaults/remote.d.ts.map +1 -1
- package/dist/vaults/remote.js +67 -23
- package/dist/vaults/remote.js.map +1 -1
- package/dist/vaults/vault.d.ts +25 -0
- package/dist/vaults/vault.d.ts.map +1 -1
- package/dist/vaults/vault.js +16 -0
- package/dist/vaults/vault.js.map +1 -1
- package/package.json +1 -1
package/dist/anyOf.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AccountSelection, CredentialSource, OAuthConnection } from "./connections.js";
|
|
2
|
+
import type { SourceResponse } from "./events.js";
|
|
3
|
+
import type { Account } from "./providers.js";
|
|
4
|
+
import type { ConnectionGrant, ConnectionHolder, ListedAccount } from "./vaults/vault.js";
|
|
5
|
+
/** One of the connections an any-of connection offers, with what the human sees for it. */
|
|
6
|
+
export type AnyOfOption = {
|
|
7
|
+
/** The connection, which no skill declares directly. */
|
|
8
|
+
connection: OAuthConnection;
|
|
9
|
+
/** What the chooser shows for it, such as "Gmail or Google Workspace". */
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
/** Options for `anyOfConnections()`. */
|
|
13
|
+
export type AnyOfConnectionOptions<Option extends string = string> = {
|
|
14
|
+
/** The provider the skill declares, which every action and notice uses, such as `email`. */
|
|
15
|
+
provider: string;
|
|
16
|
+
/** What the human picks an account of, such as "email account". */
|
|
17
|
+
label: string;
|
|
18
|
+
/** The connections the human picks an account from, keyed by a name the skill reads back, such as `gmail`. */
|
|
19
|
+
options: Record<Option, AnyOfOption>;
|
|
20
|
+
/** Reads the id or address of the account a proposal uses, such as its `account` input, which skips the chooser. */
|
|
21
|
+
select?: (selection: AccountSelection) => string | undefined;
|
|
22
|
+
};
|
|
23
|
+
/** What a task reads through an any-of connection: the option it uses, that option's account, and a token for it. */
|
|
24
|
+
export type AnyOfCredentials<Option extends string = string> = {
|
|
25
|
+
option: Option;
|
|
26
|
+
account: Account | undefined;
|
|
27
|
+
token: string;
|
|
28
|
+
};
|
|
29
|
+
/** An account the principal connected through one of an any-of connection's options. */
|
|
30
|
+
export type AnyOfAccount<Option extends string = string> = ListedAccount & {
|
|
31
|
+
option: Option;
|
|
32
|
+
};
|
|
33
|
+
/** A connection to one account of whichever of several providers the human picks, such as Gmail or Outlook. */
|
|
34
|
+
export type AnyOfConnection<Option extends string = string> = CredentialSource & {
|
|
35
|
+
/** Marks an any-of connection. */
|
|
36
|
+
readonly kind: "any-of";
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly options: Readonly<Record<Option, AnyOfOption>>;
|
|
39
|
+
/** Returns the option, account and a current token `holder` is pinned to, and throws `ConnectionRevokedError` once access is lost. */
|
|
40
|
+
credentials(holder: ConnectionHolder): Promise<AnyOfCredentials<Option>>;
|
|
41
|
+
/** Returns the account `holder` is pinned to, and throws `ConnectionRevokedError` once access is lost. */
|
|
42
|
+
account(holder: ConnectionHolder): Promise<Account | undefined>;
|
|
43
|
+
/** Answers a request to the connection's account chooser, or returns undefined when `url` isn't one. */
|
|
44
|
+
respond(url: string | URL): Promise<SourceResponse | undefined>;
|
|
45
|
+
/** Refuses every callback, which reach the options' connections instead, so the callback router tries those. */
|
|
46
|
+
callback(url: string | URL): Promise<ConnectionGrant>;
|
|
47
|
+
/** Lists the accounts the principal of `grant` connected through each option. */
|
|
48
|
+
accounts(grant: ConnectionGrant): Promise<AnyOfAccount<Option>[]>;
|
|
49
|
+
/** Revokes the principal's account `accountId` of `option`, or every account of theirs through every option when left out. */
|
|
50
|
+
revoke(principal: string, option?: Option, accountId?: string): Promise<void>;
|
|
51
|
+
};
|
|
52
|
+
/** Whether `source` is an any-of connection, whose options are the connections that hold its accounts. */
|
|
53
|
+
export declare const isAnyOfConnection: (source: object) => source is AnyOfConnection;
|
|
54
|
+
/** The connections `source` holds its accounts in: its options for an any-of connection, else itself. */
|
|
55
|
+
export declare const leavesOf: (source: CredentialSource) => CredentialSource[];
|
|
56
|
+
/**
|
|
57
|
+
* Connects a skill to one account of whichever provider the human picks, such as Gmail or Outlook. The relay sees
|
|
58
|
+
* one connection under `provider`, the agent's own chooser lists the human's accounts across every option when there
|
|
59
|
+
* are several, and each task or schedule is pinned to the one account it uses.
|
|
60
|
+
*
|
|
61
|
+
* @param options The provider to declare, what the human picks, the connections to pick from, and how a proposal names its account.
|
|
62
|
+
* @returns A connection to list in a skill's `connections`, whose `credentials()` name the option the task uses.
|
|
63
|
+
* @throws {AgentJamError} If it has fewer than two options, two options share a provider, or an option isn't an `oauthConnection()`.
|
|
64
|
+
*/
|
|
65
|
+
export declare const anyOfConnections: <Option extends string>({ provider, label, options, select, }: AnyOfConnectionOptions<Option>) => AnyOfConnection<Option>;
|
|
66
|
+
//# sourceMappingURL=anyOf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anyOf.d.ts","sourceRoot":"","sources":["../src/anyOf.ts"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 +1,135 @@
|
|
|
1
|
+
import { answerChooser, constructChooserKey, readPinned, resolveAccount, } from "./chooser.js";
|
|
2
|
+
import { choosableOf, UnknownStateError } from "./connections.js";
|
|
3
|
+
import { AgentJamError, ConnectionRevokedError } from "./errors.js";
|
|
4
|
+
import { unconnectedHolder } from "./vaults/vault.js";
|
|
5
|
+
/** Whether `source` is an any-of connection, whose options are the connections that hold its accounts. */
|
|
6
|
+
export const isAnyOfConnection = (source) => "kind" in source && source.kind === "any-of";
|
|
7
|
+
/** The connections `source` holds its accounts in: its options for an any-of connection, else itself. */
|
|
8
|
+
export const leavesOf = (source) => isAnyOfConnection(source)
|
|
9
|
+
? Object.values(source.options).map(({ connection }) => connection)
|
|
10
|
+
: [source];
|
|
11
|
+
const constructChooserOption = ([option, { connection, label }]) => {
|
|
12
|
+
const choosable = choosableOf(connection);
|
|
13
|
+
if (!choosable) {
|
|
14
|
+
throw new AgentJamError(`The "${option}" option of an any-of connection must come from oauthConnection() or a platform preset`);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
option,
|
|
18
|
+
provider: connection.provider,
|
|
19
|
+
label,
|
|
20
|
+
vault: choosable.vault,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Re-emits an option's event as the any-of connection's own, naming the option's provider on ready accounts. */
|
|
24
|
+
const asUmbrellaEvent = (provider, event) => event.type === "ready"
|
|
25
|
+
? { ...event, provider, via: event.via ?? event.provider }
|
|
26
|
+
: { ...event, provider };
|
|
27
|
+
/**
|
|
28
|
+
* Connects a skill to one account of whichever provider the human picks, such as Gmail or Outlook. The relay sees
|
|
29
|
+
* one connection under `provider`, the agent's own chooser lists the human's accounts across every option when there
|
|
30
|
+
* are several, and each task or schedule is pinned to the one account it uses.
|
|
31
|
+
*
|
|
32
|
+
* @param options The provider to declare, what the human picks, the connections to pick from, and how a proposal names its account.
|
|
33
|
+
* @returns A connection to list in a skill's `connections`, whose `credentials()` name the option the task uses.
|
|
34
|
+
* @throws {AgentJamError} If it has fewer than two options, two options share a provider, or an option isn't an `oauthConnection()`.
|
|
35
|
+
*/
|
|
36
|
+
export const anyOfConnections = ({ provider, label, options, select, }) => {
|
|
37
|
+
const entries = Object.entries(options);
|
|
38
|
+
const providers = new Set(entries.map(([, { connection }]) => connection.provider));
|
|
39
|
+
if (entries.length < 2 || providers.size !== entries.length) {
|
|
40
|
+
throw new AgentJamError(`The ${provider} any-of connection needs at least two options, each with its own provider`);
|
|
41
|
+
}
|
|
42
|
+
if (providers.has(provider)) {
|
|
43
|
+
throw new AgentJamError(`The ${provider} any-of connection can't share its provider with one of its options`);
|
|
44
|
+
}
|
|
45
|
+
const [first] = entries;
|
|
46
|
+
const choosable = choosableOf(first[1].connection);
|
|
47
|
+
const listeners = new Set();
|
|
48
|
+
const emit = (event) => {
|
|
49
|
+
for (const listener of listeners)
|
|
50
|
+
listener(event);
|
|
51
|
+
};
|
|
52
|
+
const chooser = {
|
|
53
|
+
provider,
|
|
54
|
+
label,
|
|
55
|
+
redirectUri: choosable.redirectUri,
|
|
56
|
+
key: constructChooserKey(choosable.clientSecret),
|
|
57
|
+
options: entries.map(constructChooserOption),
|
|
58
|
+
emit,
|
|
59
|
+
};
|
|
60
|
+
for (const [, { connection }] of entries) {
|
|
61
|
+
connection.watch((event) => emit(asUmbrellaEvent(provider, event)));
|
|
62
|
+
}
|
|
63
|
+
const connectionOf = (option) => options[option].connection;
|
|
64
|
+
const pinnedOf = async (holder) => {
|
|
65
|
+
const pinned = await readPinned(chooser, holder);
|
|
66
|
+
if (!pinned)
|
|
67
|
+
throw new ConnectionRevokedError(provider, unconnectedHolder);
|
|
68
|
+
return {
|
|
69
|
+
option: pinned.option.option,
|
|
70
|
+
connection: connectionOf(pinned.option.option),
|
|
71
|
+
account: pinned.account,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const accountsOf = async (grant) => {
|
|
75
|
+
const listed = await Promise.all(entries.map(async ([option, { connection }]) => (await connection.accounts(grant)).map((account) => ({
|
|
76
|
+
...account,
|
|
77
|
+
option: option,
|
|
78
|
+
}))));
|
|
79
|
+
return listed.flat();
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
kind: "any-of",
|
|
83
|
+
provider,
|
|
84
|
+
label,
|
|
85
|
+
scopes: [],
|
|
86
|
+
options,
|
|
87
|
+
authorize: (grant, { input, account, pinTo } = {}) => resolveAccount(chooser, grant, {
|
|
88
|
+
hint: account ?? select?.({ input }),
|
|
89
|
+
pinTo,
|
|
90
|
+
}),
|
|
91
|
+
constructAccessUrl: async (grant) => {
|
|
92
|
+
const { connection } = await pinnedOf(grant);
|
|
93
|
+
return connection.constructAccessUrl(grant);
|
|
94
|
+
},
|
|
95
|
+
respond: (url) => answerChooser(chooser, new URL(url, chooser.redirectUri)),
|
|
96
|
+
callback: async () => {
|
|
97
|
+
throw new UnknownStateError();
|
|
98
|
+
},
|
|
99
|
+
credentials: async (holder) => {
|
|
100
|
+
const { option, connection } = await pinnedOf(holder);
|
|
101
|
+
const [token, account] = await Promise.all([
|
|
102
|
+
connection.token(holder),
|
|
103
|
+
connection.account(holder),
|
|
104
|
+
]);
|
|
105
|
+
return { option, account, token };
|
|
106
|
+
},
|
|
107
|
+
token: async (holder, name) => {
|
|
108
|
+
const { connection } = await pinnedOf(holder);
|
|
109
|
+
return connection.token(holder, name);
|
|
110
|
+
},
|
|
111
|
+
account: async (holder) => {
|
|
112
|
+
const { connection } = await pinnedOf(holder);
|
|
113
|
+
return connection.account(holder);
|
|
114
|
+
},
|
|
115
|
+
accounts: accountsOf,
|
|
116
|
+
release: async (holder) => {
|
|
117
|
+
await Promise.all(entries.map(([, { connection }]) => connection.release(holder)));
|
|
118
|
+
},
|
|
119
|
+
revoke: async (principal, option, accountId) => {
|
|
120
|
+
const revoked = option === undefined ? entries : [[option, options[option]]];
|
|
121
|
+
for (const [, { connection }] of revoked) {
|
|
122
|
+
await connection.revoke(principal, accountId);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
listGrants: async () => {
|
|
126
|
+
const grants = await Promise.all(entries.map(([, { connection }]) => connection.listGrants()));
|
|
127
|
+
return grants.flat();
|
|
128
|
+
},
|
|
129
|
+
watch: (listener) => {
|
|
130
|
+
listeners.add(listener);
|
|
131
|
+
return () => listeners.delete(listener);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=anyOf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anyOf.js","sourceRoot":"","sources":["../src/anyOf.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,cAAc,GACf,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AASpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AA2DtD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAA6B,EAAE,CAC7E,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE/C,yGAAyG;AACzG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAwB,EAAsB,EAAE,CACvE,iBAAiB,CAAC,MAAM,CAAC;IACvB,CAAC,CAAC,MAAM,CAAC,MAAM,CAAc,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAC5C,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAC/B;IACH,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEf,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAG7D,EAAiB,EAAE;IAClB,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC1C,IA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MAAM,CAAC,CAAU,CAAC,CAAC;YAExE,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;gBACzC,MAAM,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,UAAU,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAC7D,CAAC;YAEF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC;QAED,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE;YAClB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chooser.d.ts","sourceRoot":"","sources":["../src/chooser.ts"],"names":[],"mappings":""}
|
package/dist/chooser.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { ConnectionRevokedError } from "./errors.js";
|
|
3
|
+
import { constructHtmlPage, constructPage, constructRedirect, escapeHtml, } from "./pages.js";
|
|
4
|
+
import { unnamedAccount } from "./vaults/vault.js";
|
|
5
|
+
// WARNING: a chooser link lists the principal's addresses to whoever holds it, so it expires with the relay's actions.
|
|
6
|
+
const chooserTtlMs = 60 * 60_000;
|
|
7
|
+
const signatureSeparator = "~";
|
|
8
|
+
/** @internal Derives the key that signs a connection's chooser links from its client secret. */
|
|
9
|
+
export const constructChooserKey = (clientSecret) => createHmac("sha256", clientSecret)
|
|
10
|
+
.update("agentjam account chooser")
|
|
11
|
+
.digest();
|
|
12
|
+
const sign = (key, body) => createHmac("sha256", key).update(body).digest("base64url");
|
|
13
|
+
/** Whether `state` opens this chooser, rather than another connection's or answering a provider's consent. */
|
|
14
|
+
const isChooserState = ({ provider }, state) => state.startsWith(`${provider}.`) && state.includes(signatureSeparator);
|
|
15
|
+
const mintChooserLink = ({ provider, redirectUri, key }, { requester, id, principal }) => {
|
|
16
|
+
const claims = {
|
|
17
|
+
requester,
|
|
18
|
+
id,
|
|
19
|
+
principal,
|
|
20
|
+
expiresAt: Date.now() + chooserTtlMs,
|
|
21
|
+
};
|
|
22
|
+
const encoded = Buffer.from(JSON.stringify(claims)).toString("base64url");
|
|
23
|
+
const body = `${provider}.${encoded}`;
|
|
24
|
+
const url = new URL(redirectUri);
|
|
25
|
+
url.searchParams.set("state", `${body}${signatureSeparator}${sign(key, body)}`);
|
|
26
|
+
return url.toString();
|
|
27
|
+
};
|
|
28
|
+
const readClaims = ({ key }, state) => {
|
|
29
|
+
const [body = "", signature = ""] = state.split(signatureSeparator);
|
|
30
|
+
const expected = Buffer.from(sign(key, body));
|
|
31
|
+
const given = Buffer.from(signature);
|
|
32
|
+
if (given.length !== expected.length || !timingSafeEqual(given, expected)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const encoded = body.slice(body.lastIndexOf(".") + 1);
|
|
36
|
+
const { expiresAt, ...grant } = JSON.parse(Buffer.from(encoded, "base64url").toString());
|
|
37
|
+
return expiresAt > Date.now() ? grant : undefined;
|
|
38
|
+
};
|
|
39
|
+
/** @internal Finds the option and account `holder` is pinned to, if it's pinned to any. */
|
|
40
|
+
export const readPinned = async ({ options }, holder) => {
|
|
41
|
+
for (const option of options) {
|
|
42
|
+
try {
|
|
43
|
+
const account = await option.vault.readAccount(holder);
|
|
44
|
+
return { option, account: account ?? unnamedAccount };
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (!(error instanceof ConnectionRevokedError))
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
};
|
|
53
|
+
const listChoices = async ({ options }, grant) => {
|
|
54
|
+
const listed = await Promise.all(options.map(async (option) => (await option.vault.listAccounts(grant)).map(({ account, covers }) => ({
|
|
55
|
+
option,
|
|
56
|
+
account,
|
|
57
|
+
covers,
|
|
58
|
+
}))));
|
|
59
|
+
return listed.flat();
|
|
60
|
+
};
|
|
61
|
+
const isNamed = (hint) => ({ account }) => account.id === hint || account.name?.toLowerCase() === hint.toLowerCase();
|
|
62
|
+
const boundLinkOf = (scopes, { name }) => ({ scopes, ...(name !== undefined && { loginHint: name }) });
|
|
63
|
+
/** Pins `grant` to the chosen account, returning the link that widens its grant first when it lacks scopes. */
|
|
64
|
+
const pinChoice = async ({ option, account }, grant) => {
|
|
65
|
+
const outcome = await option.vault.pin(grant, account.id);
|
|
66
|
+
switch (outcome.status) {
|
|
67
|
+
case "pinned":
|
|
68
|
+
return { url: undefined };
|
|
69
|
+
case "uncovered":
|
|
70
|
+
return {
|
|
71
|
+
url: await option.vault.bind(grant, boundLinkOf(outcome.scopes, outcome.account)),
|
|
72
|
+
};
|
|
73
|
+
case "unknown":
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @internal Pins `grant` to the account its human would pick, or returns where they connect or choose one: the
|
|
79
|
+
* account `request` names or shares, else their only account, else a consent link when a plain connection has none,
|
|
80
|
+
* else the chooser.
|
|
81
|
+
*
|
|
82
|
+
* @param chooser The connection's chooser.
|
|
83
|
+
* @param grant The task or schedule to pin.
|
|
84
|
+
* @param request The account the proposal names, or the holder whose account `grant` shares.
|
|
85
|
+
* @returns The link the human acts at, or undefined once `grant` is pinned.
|
|
86
|
+
*/
|
|
87
|
+
export const resolveAccount = async (chooser, grant, { hint, pinTo } = {}) => {
|
|
88
|
+
const shared = pinTo && (await readPinned(chooser, pinTo));
|
|
89
|
+
const kept = shared && (await pinChoice(shared, grant));
|
|
90
|
+
if (kept)
|
|
91
|
+
return kept.url;
|
|
92
|
+
const plain = chooser.options.length === 1 ? chooser.options[0] : undefined;
|
|
93
|
+
const listed = await listChoices(chooser, grant);
|
|
94
|
+
if (hint !== undefined) {
|
|
95
|
+
const named = listed.find(isNamed(hint));
|
|
96
|
+
const settled = named && (await pinChoice(named, grant));
|
|
97
|
+
if (settled)
|
|
98
|
+
return settled.url;
|
|
99
|
+
return plain
|
|
100
|
+
? plain.vault.bind(grant, { loginHint: hint })
|
|
101
|
+
: mintChooserLink(chooser, grant);
|
|
102
|
+
}
|
|
103
|
+
if (listed.length === 0 && plain)
|
|
104
|
+
return plain.vault.authorize(grant);
|
|
105
|
+
const [only] = listed;
|
|
106
|
+
if (only && listed.length === 1) {
|
|
107
|
+
return only.option.vault.authorize(grant, only.account.name);
|
|
108
|
+
}
|
|
109
|
+
return mintChooserLink(chooser, grant);
|
|
110
|
+
};
|
|
111
|
+
const constructChooserPage = ({ label, options, redirectUri }, state, listed) => {
|
|
112
|
+
const linkTo = (params) => {
|
|
113
|
+
const url = new URL(redirectUri);
|
|
114
|
+
for (const [name, value] of Object.entries({ state, ...params })) {
|
|
115
|
+
url.searchParams.set(name, value);
|
|
116
|
+
}
|
|
117
|
+
return escapeHtml(url.toString());
|
|
118
|
+
};
|
|
119
|
+
const accounts = listed.map(({ option, account, covers }) => {
|
|
120
|
+
const href = linkTo({ option: option.option, account: account.id });
|
|
121
|
+
const name = escapeHtml(account.name ?? account.id);
|
|
122
|
+
const widen = covers ? "" : " (asks for more access)";
|
|
123
|
+
return `<li><a href="${href}">${name}</a> ${escapeHtml(`${option.label}${widen}`)}</li>`;
|
|
124
|
+
});
|
|
125
|
+
const connects = options.map(({ option, label: optionLabel }) => {
|
|
126
|
+
const href = linkTo({ option, connect: "1" });
|
|
127
|
+
const text = `Connect ${listed.length > 0 ? "another" : "a"} ${optionLabel} account`;
|
|
128
|
+
return `<li><a href="${href}">${escapeHtml(text)}</a></li>`;
|
|
129
|
+
});
|
|
130
|
+
const heading = escapeHtml(`Choose the ${label} this task uses`);
|
|
131
|
+
return constructHtmlPage(200, `<h1>${heading}</h1><ul>${[...accounts, ...connects].join("")}</ul>`, { "cache-control": "no-store", "referrer-policy": "no-referrer" });
|
|
132
|
+
};
|
|
133
|
+
/** Pins `grant` to the account the human picked, or sends them to widen its grant, telling watchers once it's pinned. */
|
|
134
|
+
const pick = async (chooser, option, grant, accountId) => {
|
|
135
|
+
const outcome = await option.vault.pin(grant, accountId);
|
|
136
|
+
switch (outcome.status) {
|
|
137
|
+
case "pinned": {
|
|
138
|
+
const { account } = outcome;
|
|
139
|
+
chooser.emit({
|
|
140
|
+
type: "ready",
|
|
141
|
+
provider: chooser.provider,
|
|
142
|
+
grant,
|
|
143
|
+
account,
|
|
144
|
+
...(option.provider !== chooser.provider && { via: option.provider }),
|
|
145
|
+
});
|
|
146
|
+
const name = account.name === undefined ? "" : ` ${account.name}`;
|
|
147
|
+
return constructPage(200, `Your ${option.label} account${name} is connected, so you can close this tab.`);
|
|
148
|
+
}
|
|
149
|
+
case "uncovered":
|
|
150
|
+
return constructRedirect(await option.vault.bind(grant, boundLinkOf(outcome.scopes, outcome.account)));
|
|
151
|
+
case "unknown":
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* @internal Answers a request to a chooser link: the page listing the principal's accounts, a pick of one, which
|
|
157
|
+
* pins the holder, or a request to connect another, which redirects to that option's consent page.
|
|
158
|
+
*
|
|
159
|
+
* @param chooser The connection's chooser.
|
|
160
|
+
* @param url The request's URL.
|
|
161
|
+
* @returns The response, or undefined when `url` isn't a chooser link.
|
|
162
|
+
*/
|
|
163
|
+
export const answerChooser = async (chooser, url) => {
|
|
164
|
+
const query = url.searchParams;
|
|
165
|
+
const state = query.get("state") ?? "";
|
|
166
|
+
if (!isChooserState(chooser, state))
|
|
167
|
+
return undefined;
|
|
168
|
+
const grant = readClaims(chooser, state);
|
|
169
|
+
if (!grant) {
|
|
170
|
+
return constructPage(400, "This link expired, so ask for a new one.");
|
|
171
|
+
}
|
|
172
|
+
if (await readPinned(chooser, grant)) {
|
|
173
|
+
return constructPage(200, "This task already uses an account, so you can close this tab.");
|
|
174
|
+
}
|
|
175
|
+
const option = chooser.options.find((offered) => offered.option === query.get("option"));
|
|
176
|
+
const accountId = query.get("account");
|
|
177
|
+
const picked = option && accountId !== null
|
|
178
|
+
? await pick(chooser, option, grant, accountId)
|
|
179
|
+
: undefined;
|
|
180
|
+
if (picked)
|
|
181
|
+
return picked;
|
|
182
|
+
if (option && query.has("connect")) {
|
|
183
|
+
return constructRedirect(await option.vault.bind(grant, {}));
|
|
184
|
+
}
|
|
185
|
+
return constructChooserPage(chooser, state, await listChoices(chooser, grant));
|
|
186
|
+
};
|
|
187
|
+
//# sourceMappingURL=chooser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chooser.js","sourceRoot":"","sources":["../src/chooser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAyCnD,uHAAuH;AACvH,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC;AAEjC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,gGAAgG;AAChG,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,YAAoB,EAAE,EAAE,CAC1D,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC;KAC/B,MAAM,CAAC,0BAA0B,CAAC;KAClC,MAAM,EAAE,CAAC;AAEd,MAAM,IAAI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AM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,aAAa,CAAC,GAAG,EAAE,0CAA0C,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,aAAa,CAClB,GAAG,EACH,+DAA+D,CAChE,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CACjC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CACpD,CAAC;IACF,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvC,MAAM,MAAM,GACV,MAAM,IAAI,SAAS,KAAK,IAAI;QAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC;QAC/C,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,IAAI,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,OAAO,iBAAiB,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,oBAAoB,CACzB,OAAO,EACP,KAAK,EACL,MAAM,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAClC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/connections.d.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
+
import type { SourceResponse } from "./events.js";
|
|
1
2
|
import type { Account, AccountRevocation, OAuthEndpoints, OAuthProfile } from "./providers.js";
|
|
2
3
|
import type { ConnectionScopes, SkillConnection } from "./types.js";
|
|
3
|
-
import type { ConnectionEvent, ConnectionGrant, ConnectionHolder, ConnectionStore } from "./vaults/vault.js";
|
|
4
|
+
import type { ConnectionEvent, ConnectionGrant, ConnectionHolder, ConnectionStore, ListedAccount } from "./vaults/vault.js";
|
|
4
5
|
export { UnknownStateError } from "./vaults/vault.js";
|
|
5
|
-
export type { ConnectionEvent, ConnectionGrant, ConnectionHolder, ConnectionStore, } from "./vaults/vault.js";
|
|
6
|
+
export type { ConnectionEvent, ConnectionGrant, ConnectionHolder, ConnectionStore, ListedAccount, } from "./vaults/vault.js";
|
|
6
7
|
export declare const constructScopeRecord: (scopes: ConnectionScopes, token?: string) => Record<string, string[]>;
|
|
8
|
+
/** What a source knows about the proposal it authorizes, which decides the account the proposal's work uses. */
|
|
9
|
+
export type AuthorizeRequest = {
|
|
10
|
+
/** The proposal's input, which the connection's `select` reads an account from. */
|
|
11
|
+
input?: unknown;
|
|
12
|
+
/** The id or address of the account to use, which overrides the one `select` reads. */
|
|
13
|
+
account?: string;
|
|
14
|
+
/** Another task or schedule of the same human whose account to use, such as the task that set up a background job. */
|
|
15
|
+
pinTo?: ConnectionHolder;
|
|
16
|
+
};
|
|
17
|
+
/** What a connection's `select` reads the account to use from. */
|
|
18
|
+
export type AccountSelection = {
|
|
19
|
+
input: unknown;
|
|
20
|
+
};
|
|
7
21
|
/**
|
|
8
|
-
* Gives an executor access to a human's
|
|
9
|
-
*
|
|
10
|
-
* credential vault can implement it instead.
|
|
22
|
+
* Gives an executor access to a human's accounts with `provider`. Each human can connect several, and each task
|
|
23
|
+
* or schedule is pinned to one of them, which every agent's tasks for that human can share. `oauthConnection()`
|
|
24
|
+
* builds one, and a credential vault can implement it instead.
|
|
11
25
|
*/
|
|
12
26
|
export interface CredentialSource<Token extends string = string> extends SkillConnection {
|
|
13
|
-
/**
|
|
14
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Pins `grant` to one of the principal's accounts, or returns where they connect or choose one: the account
|
|
29
|
+
* `request` names, else their only account that covers the scopes, else a chooser or a consent link.
|
|
30
|
+
*/
|
|
31
|
+
authorize(grant: ConnectionGrant, request?: AuthorizeRequest): Promise<string | undefined>;
|
|
15
32
|
/** Returns where the principal changes what their account lets `grant` reach, such as which repositories, once a running task lacks access. */
|
|
16
33
|
constructAccessUrl?(grant: ConnectionGrant): Promise<string>;
|
|
17
34
|
/** Returns a current access token for `holder`, the one named `name` if given, and throws `ConnectionRevokedError` once access is lost. */
|
|
@@ -49,6 +66,8 @@ export type OAuthSettings<Token extends string = string> = SkillConnection<Token
|
|
|
49
66
|
accessUrl?: string;
|
|
50
67
|
/** Revokes access with the provider once no task or schedule uses a grant, instead of keeping it for later ones. Defaults to false. */
|
|
51
68
|
revokeOnEnd?: boolean;
|
|
69
|
+
/** Reads the id or address of the account a proposal uses, such as its `account` input, which skips the chooser. */
|
|
70
|
+
select?: (selection: AccountSelection) => string | undefined;
|
|
52
71
|
};
|
|
53
72
|
/** Options for `oauthConnection()`, which runs the provider's flow from either its `endpoints` or a `profile`. */
|
|
54
73
|
export type OAuthConnectionOptions<Token extends string = string> = OAuthSettings<Token> & ({
|
|
@@ -79,13 +98,25 @@ export type OAuthConnection<Token extends string = string> = CredentialSource<To
|
|
|
79
98
|
*/
|
|
80
99
|
callback(url: string | URL): Promise<ConnectionGrant>;
|
|
81
100
|
/**
|
|
82
|
-
*
|
|
101
|
+
* Answers a request to the connection's account chooser, which `authorize` links to once the human must pick
|
|
102
|
+
* one of several accounts. A custom server passes each request at `redirectUri` here before `callback()`.
|
|
103
|
+
*
|
|
104
|
+
* @param url The request's URL, absolute or relative to `redirectUri`.
|
|
105
|
+
* @returns The chooser's response, or undefined when `url` is a provider's callback rather than the chooser.
|
|
106
|
+
*/
|
|
107
|
+
respond(url: string | URL): Promise<SourceResponse | undefined>;
|
|
108
|
+
/** Lists the accounts the principal of `grant` connected, with whether each covers the connection's scopes. */
|
|
109
|
+
accounts(grant: ConnectionGrant): Promise<ListedAccount[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Revokes a human's grant for one account with the provider, or for each of their accounts, and forgets its
|
|
112
|
+
* tokens, which ends every task and schedule that uses it.
|
|
83
113
|
*
|
|
84
114
|
* @param principal The human whose account to disconnect.
|
|
85
|
-
* @
|
|
115
|
+
* @param accountId The account to disconnect, or every one of the human's when left out.
|
|
116
|
+
* @returns Resolves once the grants are revoked.
|
|
86
117
|
* @throws {AgentJamError} If the provider refuses the revocation.
|
|
87
118
|
*/
|
|
88
|
-
revoke(principal: string): Promise<void>;
|
|
119
|
+
revoke(principal: string, accountId?: string): Promise<void>;
|
|
89
120
|
};
|
|
90
121
|
/**
|
|
91
122
|
* Connects a skill to a human's account with an OAuth 2.0 provider. Each human connects once, and their
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,YAAY,EAIb,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQpE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EAEf,aAAa,EAId,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAkB3B,eAAO,MAAM,oBAAoB,WACvB,gBAAgB,qBAEvB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAKnB,CAAC;AAER,gHAAgH;AAChH,MAAM,MAAM,gBAAgB,GAAG;I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