@every-app/sdk 0.3.0-rc.1 → 0.3.0-rc.2
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/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.d.ts.map +1 -1
- package/dist/cloudflare/worker.d.ts +88 -7
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +85 -6
- package/dist/internal/capabilities.d.ts +1933 -28
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/capabilities.js +11 -0
- package/dist/internal/catalog/commerce.d.ts +394 -0
- package/dist/internal/catalog/commerce.d.ts.map +1 -0
- package/dist/internal/catalog/commerce.js +477 -0
- package/dist/internal/catalog/comms.d.ts +338 -0
- package/dist/internal/catalog/comms.d.ts.map +1 -0
- package/dist/internal/catalog/comms.js +477 -0
- package/dist/internal/catalog/index.d.ts +1899 -0
- package/dist/internal/catalog/index.d.ts.map +1 -0
- package/dist/internal/catalog/index.js +19 -0
- package/dist/internal/catalog/inference.d.ts +356 -0
- package/dist/internal/catalog/inference.d.ts.map +1 -0
- package/dist/internal/catalog/inference.js +425 -0
- package/dist/internal/catalog/infra.d.ts +423 -0
- package/dist/internal/catalog/infra.d.ts.map +1 -0
- package/dist/internal/catalog/infra.js +543 -0
- package/dist/internal/catalog/search.d.ts +400 -0
- package/dist/internal/catalog/search.d.ts.map +1 -0
- package/dist/internal/catalog/search.js +463 -0
- package/dist/internal/events.d.ts +1 -1
- package/dist/internal/events.d.ts.map +1 -1
- package/dist/internal/events.js +2 -0
- package/dist/internal/gatewaySettings.d.ts +2 -1
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +10 -2
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +4 -0
- package/dist/internal/providerSpec.d.ts.map +1 -1
- package/dist/internal/providerSpec.js +17 -5
- package/dist/internal/signInProviders.d.ts +104 -0
- package/dist/internal/signInProviders.d.ts.map +1 -0
- package/dist/internal/signInProviders.js +238 -0
- package/package.json +12 -12
|
@@ -26,7 +26,12 @@ const SEGMENT = /^[a-z0-9_-]{1,64}$/;
|
|
|
26
26
|
const HEADER_NAME = /^[A-Za-z0-9-]{1,64}$/;
|
|
27
27
|
const QUERY_PARAM = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
28
28
|
const SCHEME = /^[A-Za-z][A-Za-z0-9-]{0,31}$/;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* A JSON field name, or a dotted path to a nested one (`usage.cost`, at
|
|
31
|
+
* most four segments): the capability proxy reads a top-level name off the
|
|
32
|
+
* answer's head, the AI proxy a path into the usage object off its tail.
|
|
33
|
+
*/
|
|
34
|
+
const RESPONSE_FIELD = /^[A-Za-z_][A-Za-z0-9_]{0,63}(?:\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/;
|
|
30
35
|
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
31
36
|
const TAG = /^[a-z][a-z0-9-]{0,31}$/;
|
|
32
37
|
/** Control and format characters: in no text a spec carries. */
|
|
@@ -475,11 +480,11 @@ function cost(value, problems) {
|
|
|
475
480
|
}
|
|
476
481
|
const usd = nonNegative(value["usd"], "cost.usd", problems);
|
|
477
482
|
const note = text(value["note"], "cost.note", problems, { max: 200 });
|
|
478
|
-
const responseField = text(value["responseField"], "cost.responseField", problems, { max:
|
|
483
|
+
const responseField = text(value["responseField"], "cost.responseField", problems, { max: 128 });
|
|
479
484
|
if (responseField !== undefined && !RESPONSE_FIELD.test(responseField)) {
|
|
480
485
|
problems.push({
|
|
481
486
|
path: "cost.responseField",
|
|
482
|
-
message: "must be a JSON field name",
|
|
487
|
+
message: "must be a JSON field name, or a dotted path to a nested one",
|
|
483
488
|
});
|
|
484
489
|
}
|
|
485
490
|
if (unit !== "call" && unit !== "result" && unit !== "token")
|
|
@@ -635,8 +640,15 @@ export function parseProviderSpec(input) {
|
|
|
635
640
|
problems.push({ path: "access", message: "must list read, write or both" });
|
|
636
641
|
}
|
|
637
642
|
const readMethods = methods(input["readMethods"], "readMethods", problems);
|
|
638
|
-
|
|
639
|
-
|
|
643
|
+
// A write-only provider (a sender, a GraphQL API) reads with nothing:
|
|
644
|
+
// every call needs the write grant. Anything that offers read lists how.
|
|
645
|
+
if (readMethods &&
|
|
646
|
+
readMethods.length === 0 &&
|
|
647
|
+
(!Array.isArray(access) || access.includes("read"))) {
|
|
648
|
+
problems.push({
|
|
649
|
+
path: "readMethods",
|
|
650
|
+
message: "must list a method unless access is write alone",
|
|
651
|
+
});
|
|
640
652
|
}
|
|
641
653
|
const writeMethods = methods(input["writeMethods"], "writeMethods", problems);
|
|
642
654
|
const paths = accountWidePaths(input["accountWidePaths"], problems);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sign-in providers a Gateway can offer beside passwords ("Continue
|
|
3
|
+
* with Google"), as data: what each one is called, the Worker secrets it
|
|
4
|
+
* reads, where the OAuth app is made, the scopes asked for and which claim
|
|
5
|
+
* becomes the email. One catalog serves the Gateway (which providers are
|
|
6
|
+
* on, the sign-in page's buttons, Manage workspace → Sign-in), the CLI
|
|
7
|
+
* (`everyapp signin add|list|show|remove`, `secret set`), the manifest
|
|
8
|
+
* validator (an app's own secret can never take one of these names) and
|
|
9
|
+
* the docs' drift tests.
|
|
10
|
+
*
|
|
11
|
+
* Naming rule, agreed with the provider registry's conventions
|
|
12
|
+
* (docs/design/2026-10-provider-registry.md, section 6): a sign-in
|
|
13
|
+
* provider's settings are `<ID>_SIGNIN_<FIELD>`, with FIELD one of
|
|
14
|
+
* CLIENT_ID, CLIENT_SECRET, ISSUER, LABEL or TENANT. The `_SIGNIN_` infix is
|
|
15
|
+
* what keeps the family apart from the API providers' `<ID>_API_KEY`,
|
|
16
|
+
* `<ID>_CLIENT_ID` (the OAuth clients the Gateway holds for apps) and the
|
|
17
|
+
* MCP apps' `<ID>_MCP_TOKEN`: `GOOGLE_SIGNIN_CLIENT_ID` is the sign-in
|
|
18
|
+
* provider's, `GOOGLE_WORKSPACE_CLIENT_ID` the OAuth client apps use, and
|
|
19
|
+
* a registered provider row or an app manifest can never claim a name in
|
|
20
|
+
* the family (isSignInSettingName).
|
|
21
|
+
*
|
|
22
|
+
* The settings are Worker secrets, set under the Cloudflare login (`everyapp
|
|
23
|
+
* signin add`, or `secret set`), never from the admin UI or an agent
|
|
24
|
+
* connection: a stolen session can't add a way in.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SIGN_IN_PROVIDER_IDS: readonly ["google", "microsoft", "github", "apple", "cloudflare", "oidc"];
|
|
27
|
+
export type SignInProviderId = (typeof SIGN_IN_PROVIDER_IDS)[number];
|
|
28
|
+
/** What a setting of a sign-in provider holds. */
|
|
29
|
+
export type SignInSettingRole = "clientId" | "clientSecret" | "issuer" | "label" | "tenant";
|
|
30
|
+
export interface SignInSetting {
|
|
31
|
+
/** `GOOGLE_SIGNIN_CLIENT_ID`. */
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly role: SignInSettingRole;
|
|
34
|
+
/** Without it the provider is off (an incomplete set is reported). */
|
|
35
|
+
readonly required: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* A plain value (an id, a URL, a word) `everyapp secret set` may show as
|
|
38
|
+
* typed; a credential stays hidden.
|
|
39
|
+
*/
|
|
40
|
+
readonly plain: boolean;
|
|
41
|
+
/** One line: what to paste here. */
|
|
42
|
+
readonly what: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SignInProvider {
|
|
45
|
+
readonly id: SignInProviderId;
|
|
46
|
+
/** The button: "Continue with <label>". The `oidc` entry's label is a setting. */
|
|
47
|
+
readonly label: string;
|
|
48
|
+
/** Where the OAuth app is created. */
|
|
49
|
+
readonly console: string;
|
|
50
|
+
/** What the OAuth app is called there ("OAuth client ID", "App registration"). */
|
|
51
|
+
readonly appNoun: string;
|
|
52
|
+
readonly settings: readonly SignInSetting[];
|
|
53
|
+
/** The scopes requested: identity only, nothing an app could act with. */
|
|
54
|
+
readonly scopes: readonly string[];
|
|
55
|
+
/** Which claim becomes the email, and what makes it count as verified. */
|
|
56
|
+
readonly emailClaim: string;
|
|
57
|
+
/** The everyapp skill's setup guide, relative to the skill. */
|
|
58
|
+
readonly setup: `setup/signin-${SignInProviderId}.md`;
|
|
59
|
+
/** Caveats worth a line in every listing. */
|
|
60
|
+
readonly notes: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/** The path Better Auth serves the provider's callback on, under the Gateway's URL. */
|
|
63
|
+
export declare function signInCallbackPath(id: SignInProviderId): string;
|
|
64
|
+
/** The redirect URL to register with the provider, for a Gateway at `gatewayUrl`. */
|
|
65
|
+
export declare function signInCallbackUrl(gatewayUrl: string, id: SignInProviderId): string;
|
|
66
|
+
export declare const SIGN_IN_PROVIDERS: Readonly<Record<SignInProviderId, SignInProvider>>;
|
|
67
|
+
/** The catalog in listing order. */
|
|
68
|
+
export declare const SIGN_IN_PROVIDER_LIST: readonly SignInProvider[];
|
|
69
|
+
export declare function isSignInProviderId(value: string): value is SignInProviderId;
|
|
70
|
+
/**
|
|
71
|
+
* Every setting a sign-in provider reads, in catalog order: what `everyapp
|
|
72
|
+
* secret set` accepts for the Gateway, and what the Gateway's dev config
|
|
73
|
+
* declares.
|
|
74
|
+
*/
|
|
75
|
+
export declare const SIGN_IN_GATEWAY_SETTINGS: readonly string[];
|
|
76
|
+
/** The plain (non-credential) ones among them: ids, the issuer, the label, the tenant. */
|
|
77
|
+
export declare const PLAIN_SIGN_IN_SETTINGS: readonly string[];
|
|
78
|
+
/**
|
|
79
|
+
* The family: any name of the shape `<ID>_SIGNIN_<FIELD>`. Reserved for the
|
|
80
|
+
* catalog above, whether or not an entry reads the name today, so no
|
|
81
|
+
* registered provider row and no app manifest can ever take one.
|
|
82
|
+
*/
|
|
83
|
+
export declare const SIGN_IN_SETTING_PATTERN: RegExp;
|
|
84
|
+
export declare function isSignInSettingName(name: string): boolean;
|
|
85
|
+
/** The provider a setting belongs to, if one reads it. */
|
|
86
|
+
export declare function signInProviderOfSetting(name: string): SignInProvider | null;
|
|
87
|
+
/** Whether a provider is on, off, or half set up, from which names are set. */
|
|
88
|
+
export type SignInProviderStatus = "on" | "off" | "incomplete";
|
|
89
|
+
export interface SignInProviderState {
|
|
90
|
+
readonly id: SignInProviderId;
|
|
91
|
+
readonly status: SignInProviderStatus;
|
|
92
|
+
/** The required settings not set (empty when on or off). */
|
|
93
|
+
readonly missing: readonly string[];
|
|
94
|
+
/** The settings set, required or not. */
|
|
95
|
+
readonly set: readonly string[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A provider's state from which of its settings exist: on when every
|
|
99
|
+
* required one is set, off when none at all is, incomplete in between (the
|
|
100
|
+
* Gateway refuses to half-configure a sign-in: the provider is off and the
|
|
101
|
+
* problem is reported).
|
|
102
|
+
*/
|
|
103
|
+
export declare function signInProviderState(provider: SignInProvider, isSet: (name: string) => boolean): SignInProviderState;
|
|
104
|
+
//# sourceMappingURL=signInProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signInProviders.d.ts","sourceRoot":"","sources":["../../src/internal/signInProviders.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sign-in providers a Gateway can offer beside passwords ("Continue
|
|
3
|
+
* with Google"), as data: what each one is called, the Worker secrets it
|
|
4
|
+
* reads, where the OAuth app is made, the scopes asked for and which claim
|
|
5
|
+
* becomes the email. One catalog serves the Gateway (which providers are
|
|
6
|
+
* on, the sign-in page's buttons, Manage workspace → Sign-in), the CLI
|
|
7
|
+
* (`everyapp signin add|list|show|remove`, `secret set`), the manifest
|
|
8
|
+
* validator (an app's own secret can never take one of these names) and
|
|
9
|
+
* the docs' drift tests.
|
|
10
|
+
*
|
|
11
|
+
* Naming rule, agreed with the provider registry's conventions
|
|
12
|
+
* (docs/design/2026-10-provider-registry.md, section 6): a sign-in
|
|
13
|
+
* provider's settings are `<ID>_SIGNIN_<FIELD>`, with FIELD one of
|
|
14
|
+
* CLIENT_ID, CLIENT_SECRET, ISSUER, LABEL or TENANT. The `_SIGNIN_` infix is
|
|
15
|
+
* what keeps the family apart from the API providers' `<ID>_API_KEY`,
|
|
16
|
+
* `<ID>_CLIENT_ID` (the OAuth clients the Gateway holds for apps) and the
|
|
17
|
+
* MCP apps' `<ID>_MCP_TOKEN`: `GOOGLE_SIGNIN_CLIENT_ID` is the sign-in
|
|
18
|
+
* provider's, `GOOGLE_WORKSPACE_CLIENT_ID` the OAuth client apps use, and
|
|
19
|
+
* a registered provider row or an app manifest can never claim a name in
|
|
20
|
+
* the family (isSignInSettingName).
|
|
21
|
+
*
|
|
22
|
+
* The settings are Worker secrets, set under the Cloudflare login (`everyapp
|
|
23
|
+
* signin add`, or `secret set`), never from the admin UI or an agent
|
|
24
|
+
* connection: a stolen session can't add a way in.
|
|
25
|
+
*/
|
|
26
|
+
export const SIGN_IN_PROVIDER_IDS = [
|
|
27
|
+
"google",
|
|
28
|
+
"microsoft",
|
|
29
|
+
"github",
|
|
30
|
+
"apple",
|
|
31
|
+
"cloudflare",
|
|
32
|
+
"oidc",
|
|
33
|
+
];
|
|
34
|
+
/** The path Better Auth serves the provider's callback on, under the Gateway's URL. */
|
|
35
|
+
export function signInCallbackPath(id) {
|
|
36
|
+
return `/api/auth/callback/${id}`;
|
|
37
|
+
}
|
|
38
|
+
/** The redirect URL to register with the provider, for a Gateway at `gatewayUrl`. */
|
|
39
|
+
export function signInCallbackUrl(gatewayUrl, id) {
|
|
40
|
+
return `${gatewayUrl.replace(/\/+$/, "")}${signInCallbackPath(id)}`;
|
|
41
|
+
}
|
|
42
|
+
function settingName(id, field) {
|
|
43
|
+
return `${id.toUpperCase()}_SIGNIN_${field}`;
|
|
44
|
+
}
|
|
45
|
+
function clientPair(id, what) {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
name: settingName(id, "CLIENT_ID"),
|
|
49
|
+
role: "clientId",
|
|
50
|
+
required: true,
|
|
51
|
+
plain: true,
|
|
52
|
+
what: what.clientId,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: settingName(id, "CLIENT_SECRET"),
|
|
56
|
+
role: "clientSecret",
|
|
57
|
+
required: true,
|
|
58
|
+
plain: false,
|
|
59
|
+
what: what.clientSecret,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
const IDENTITY_SCOPES = ["openid", "email", "profile"];
|
|
64
|
+
export const SIGN_IN_PROVIDERS = {
|
|
65
|
+
google: {
|
|
66
|
+
id: "google",
|
|
67
|
+
label: "Google",
|
|
68
|
+
console: "https://console.cloud.google.com/apis/credentials",
|
|
69
|
+
appNoun: "OAuth client ID (Web application)",
|
|
70
|
+
settings: clientPair("google", {
|
|
71
|
+
clientId: "The OAuth client's Client ID (ends in .apps.googleusercontent.com)",
|
|
72
|
+
clientSecret: "The OAuth client's Client secret",
|
|
73
|
+
}),
|
|
74
|
+
scopes: IDENTITY_SCOPES,
|
|
75
|
+
emailClaim: "the ID token's `email`, counted as verified only when its `email_verified` is true (every Google account's own address is)",
|
|
76
|
+
setup: "setup/signin-google.md",
|
|
77
|
+
notes: [
|
|
78
|
+
"An OAuth consent screen still in Testing only signs in the test users listed on it; publish it for everyone else.",
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
microsoft: {
|
|
82
|
+
id: "microsoft",
|
|
83
|
+
label: "Microsoft",
|
|
84
|
+
console: "https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
|
|
85
|
+
appNoun: "App registration",
|
|
86
|
+
settings: [
|
|
87
|
+
...clientPair("microsoft", {
|
|
88
|
+
clientId: "The app registration's Application (client) ID",
|
|
89
|
+
clientSecret: "A client secret from Certificates & secrets (it expires; 24 months at most)",
|
|
90
|
+
}),
|
|
91
|
+
{
|
|
92
|
+
name: settingName("microsoft", "TENANT"),
|
|
93
|
+
role: "tenant",
|
|
94
|
+
required: false,
|
|
95
|
+
plain: true,
|
|
96
|
+
what: "The Directory (tenant) ID to pin sign-in to your own directory; unset means any Microsoft account (common), which then needs the xms_edov claim",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
scopes: IDENTITY_SCOPES,
|
|
100
|
+
emailClaim: "the ID token's `email`, counted as verified when MICROSOFT_SIGNIN_TENANT pins your own directory, or the token carries `xms_edov: true` (the optional claim that says the domain's owner verified it), `email_verified: true`, a matching `verified_primary_email`, or comes from a personal Microsoft account",
|
|
101
|
+
setup: "setup/signin-microsoft.md",
|
|
102
|
+
notes: [
|
|
103
|
+
"Without MICROSOFT_SIGNIN_TENANT, add the optional claims `email` and `xms_edov` under Token configuration, or every sign-in is refused as unverified: any tenant's admin can put any address on their users.",
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
github: {
|
|
107
|
+
id: "github",
|
|
108
|
+
label: "GitHub",
|
|
109
|
+
console: "https://github.com/settings/developers",
|
|
110
|
+
appNoun: "OAuth App",
|
|
111
|
+
settings: clientPair("github", {
|
|
112
|
+
clientId: "The OAuth App's Client ID",
|
|
113
|
+
clientSecret: "A client secret generated on the OAuth App",
|
|
114
|
+
}),
|
|
115
|
+
scopes: ["read:user", "user:email"],
|
|
116
|
+
emailClaim: "the primary address from GitHub's emails API, counted as verified only when GitHub marks it verified",
|
|
117
|
+
setup: "setup/signin-github.md",
|
|
118
|
+
notes: [
|
|
119
|
+
"GitHub Apps are something else: make an OAuth App (Settings → Developer settings → OAuth Apps).",
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
apple: {
|
|
123
|
+
id: "apple",
|
|
124
|
+
label: "Apple",
|
|
125
|
+
console: "https://developer.apple.com/account/resources/identifiers/list/serviceId",
|
|
126
|
+
appNoun: "Services ID",
|
|
127
|
+
settings: clientPair("apple", {
|
|
128
|
+
clientId: "The Services ID's identifier (com.example.gateway)",
|
|
129
|
+
clientSecret: "The client secret JWT you generate from your Sign in with Apple key (ES256; valid six months at most, then generate it again)",
|
|
130
|
+
}),
|
|
131
|
+
scopes: ["email", "name"],
|
|
132
|
+
emailClaim: "the ID token's `email`, counted as verified only when its `email_verified` is true; someone who chose Hide My Email arrives as a @privaterelay.appleid.com address, which no invitation names",
|
|
133
|
+
setup: "setup/signin-apple.md",
|
|
134
|
+
notes: [
|
|
135
|
+
"Apple returns to the Gateway with a POST; behind the outer ring, `everyapp access on` leaves /api/auth/callback/apple public (it only redirects to the same URL as a GET, which Access then checks).",
|
|
136
|
+
"The client secret is a JWT that expires within six months: generate a new one before then or sign-in stops.",
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
cloudflare: {
|
|
140
|
+
id: "cloudflare",
|
|
141
|
+
label: "Cloudflare",
|
|
142
|
+
console: "https://dash.cloudflare.com/?to=/:account/oauth-clients",
|
|
143
|
+
appNoun: "OAuth client (Manage Account → OAuth clients)",
|
|
144
|
+
settings: clientPair("cloudflare", {
|
|
145
|
+
clientId: "The OAuth client's Client ID",
|
|
146
|
+
clientSecret: "The OAuth client's Client secret",
|
|
147
|
+
}),
|
|
148
|
+
scopes: ["user-details.read"],
|
|
149
|
+
emailClaim: "the Cloudflare API's /user `email` (the account's sign-in address). Cloudflare reports no verified flag, so the email counts as verified on the strength of the client being private: only members of your Cloudflare account can authorize it, and they got in by accepting an invitation sent to that address",
|
|
150
|
+
setup: "setup/signin-cloudflare.md",
|
|
151
|
+
notes: [
|
|
152
|
+
"Keep the client private (the default): a public client lets any Cloudflare user sign in, and Cloudflare says nothing about whether their address is verified. Making a client public is permanent.",
|
|
153
|
+
"The Cloudflare account's members sign in; for everyone else use Cloudflare Access's one-time PIN (`everyapp access on`) or another provider.",
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
oidc: {
|
|
157
|
+
id: "oidc",
|
|
158
|
+
label: "SSO",
|
|
159
|
+
console: "your identity provider's admin console",
|
|
160
|
+
appNoun: "OpenID Connect client (web application, authorization code)",
|
|
161
|
+
settings: [
|
|
162
|
+
{
|
|
163
|
+
name: settingName("oidc", "ISSUER"),
|
|
164
|
+
role: "issuer",
|
|
165
|
+
required: true,
|
|
166
|
+
plain: true,
|
|
167
|
+
what: "The issuer URL (https://…), which serves /.well-known/openid-configuration",
|
|
168
|
+
},
|
|
169
|
+
...clientPair("oidc", {
|
|
170
|
+
clientId: "The client ID",
|
|
171
|
+
clientSecret: "The client secret",
|
|
172
|
+
}),
|
|
173
|
+
{
|
|
174
|
+
name: settingName("oidc", "LABEL"),
|
|
175
|
+
role: "label",
|
|
176
|
+
required: false,
|
|
177
|
+
plain: true,
|
|
178
|
+
what: 'The button text after "Continue with" (default "SSO")',
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
scopes: IDENTITY_SCOPES,
|
|
182
|
+
emailClaim: "the ID token's `email` (else the userinfo endpoint's), counted as verified only when `email_verified` is true",
|
|
183
|
+
setup: "setup/signin-oidc.md",
|
|
184
|
+
notes: [
|
|
185
|
+
"Cloudflare Access has its own settings (CLOUDFLARE_ACCESS_OIDC_*, `everyapp access`): use those for Access, this for Okta, Entra ID, Google Workspace as an OIDC issuer, Keycloak, Auth0 and the like.",
|
|
186
|
+
"ID tokens must be signed with RS256 (every major provider's default).",
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
/** The catalog in listing order. */
|
|
191
|
+
export const SIGN_IN_PROVIDER_LIST = SIGN_IN_PROVIDER_IDS.map((id) => SIGN_IN_PROVIDERS[id]);
|
|
192
|
+
export function isSignInProviderId(value) {
|
|
193
|
+
return SIGN_IN_PROVIDER_IDS.includes(value);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Every setting a sign-in provider reads, in catalog order: what `everyapp
|
|
197
|
+
* secret set` accepts for the Gateway, and what the Gateway's dev config
|
|
198
|
+
* declares.
|
|
199
|
+
*/
|
|
200
|
+
export const SIGN_IN_GATEWAY_SETTINGS = SIGN_IN_PROVIDER_LIST.flatMap((provider) => provider.settings.map((setting) => setting.name));
|
|
201
|
+
/** The plain (non-credential) ones among them: ids, the issuer, the label, the tenant. */
|
|
202
|
+
export const PLAIN_SIGN_IN_SETTINGS = SIGN_IN_PROVIDER_LIST.flatMap((provider) => provider.settings
|
|
203
|
+
.filter((setting) => setting.plain)
|
|
204
|
+
.map((setting) => setting.name));
|
|
205
|
+
/**
|
|
206
|
+
* The family: any name of the shape `<ID>_SIGNIN_<FIELD>`. Reserved for the
|
|
207
|
+
* catalog above, whether or not an entry reads the name today, so no
|
|
208
|
+
* registered provider row and no app manifest can ever take one.
|
|
209
|
+
*/
|
|
210
|
+
export const SIGN_IN_SETTING_PATTERN = /^[A-Z][A-Z0-9_]*_SIGNIN_(CLIENT_ID|CLIENT_SECRET|ISSUER|LABEL|TENANT)$/;
|
|
211
|
+
export function isSignInSettingName(name) {
|
|
212
|
+
return SIGN_IN_SETTING_PATTERN.test(name);
|
|
213
|
+
}
|
|
214
|
+
/** The provider a setting belongs to, if one reads it. */
|
|
215
|
+
export function signInProviderOfSetting(name) {
|
|
216
|
+
for (const provider of SIGN_IN_PROVIDER_LIST) {
|
|
217
|
+
if (provider.settings.some((setting) => setting.name === name)) {
|
|
218
|
+
return provider;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* A provider's state from which of its settings exist: on when every
|
|
225
|
+
* required one is set, off when none at all is, incomplete in between (the
|
|
226
|
+
* Gateway refuses to half-configure a sign-in: the provider is off and the
|
|
227
|
+
* problem is reported).
|
|
228
|
+
*/
|
|
229
|
+
export function signInProviderState(provider, isSet) {
|
|
230
|
+
const set = provider.settings
|
|
231
|
+
.filter((setting) => isSet(setting.name))
|
|
232
|
+
.map((setting) => setting.name);
|
|
233
|
+
const missing = provider.settings
|
|
234
|
+
.filter((setting) => setting.required && !isSet(setting.name))
|
|
235
|
+
.map((setting) => setting.name);
|
|
236
|
+
const status = missing.length === 0 ? "on" : set.length === 0 ? "off" : "incomplete";
|
|
237
|
+
return { id: provider.id, status, missing, set };
|
|
238
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@every-app/sdk",
|
|
3
|
-
"version": "0.3.0-rc.
|
|
3
|
+
"version": "0.3.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,16 +30,6 @@
|
|
|
30
30
|
"dist",
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
|
-
"scripts": {
|
|
34
|
-
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
35
|
-
"build": "tsc -p tsconfig.build.json",
|
|
36
|
-
"types:check": "tsc --noEmit",
|
|
37
|
-
"format:check": "prettier --check .",
|
|
38
|
-
"format:write": "prettier . --write",
|
|
39
|
-
"test": "vitest run --silent",
|
|
40
|
-
"test:watch": "vitest",
|
|
41
|
-
"check:esm-relative-imports": "node ./scripts/check-esm-relative-imports.mjs"
|
|
42
|
-
},
|
|
43
33
|
"peerDependencies": {
|
|
44
34
|
"jose": "^6.2.5"
|
|
45
35
|
},
|
|
@@ -53,5 +43,15 @@
|
|
|
53
43
|
"vite-tsconfig-paths": "^5.1.4",
|
|
54
44
|
"vitest": "^3.2.6",
|
|
55
45
|
"zod": "^4.2.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"types:check": "tsc --noEmit",
|
|
51
|
+
"format:check": "prettier --check .",
|
|
52
|
+
"format:write": "prettier . --write",
|
|
53
|
+
"test": "vitest run --silent",
|
|
54
|
+
"test:watch": "vitest",
|
|
55
|
+
"check:esm-relative-imports": "node ./scripts/check-esm-relative-imports.mjs"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|