@hraness/suite-accounts 0.9.20
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 +496 -0
- package/compiler-foundation.css +1 -0
- package/dist/auth-client.js +16 -0
- package/dist/auth-proxy.js +757 -0
- package/dist/bearer-verifier.js +1119 -0
- package/dist/browser-session.js +208 -0
- package/dist/client-configuration.js +470 -0
- package/dist/convex-browser-auth-browser.js +923 -0
- package/dist/convex-browser-auth-server.js +846 -0
- package/dist/convex-browser-auth.js +597 -0
- package/dist/entitlements.js +502 -0
- package/dist/identity/functions.js +44 -0
- package/dist/identity/index.js +1716 -0
- package/dist/identity/return-targets.js +33 -0
- package/dist/index.js +1133 -0
- package/dist/oidc-device-code.js +253 -0
- package/dist/oidc-rp.js +2259 -0
- package/dist/oidc-session-policy.js +5 -0
- package/dist/oidc-surface-server.js +2332 -0
- package/dist/profile-form.js +1934 -0
- package/dist/profile.js +17 -0
- package/dist/public-config.js +462 -0
- package/dist/react.js +137 -0
- package/dist/receipt-verifier.js +619 -0
- package/dist/registry.js +327 -0
- package/dist/stylex-manifest.json +1 -0
- package/dist/stylex.css +435 -0
- package/dist/urls.js +391 -0
- package/package.json +263 -0
- package/portfolio-inventory.json +37 -0
- package/src/auth-client.ts +37 -0
- package/src/auth-proxy.ts +473 -0
- package/src/bearer-verifier.ts +478 -0
- package/src/browser-session.ts +260 -0
- package/src/client-configuration.ts +172 -0
- package/src/convex-browser-auth-browser.ts +238 -0
- package/src/convex-browser-auth-server.ts +492 -0
- package/src/convex-browser-auth.ts +208 -0
- package/src/convex-url.ts +74 -0
- package/src/entitlements.ts +317 -0
- package/src/identity/catalog.ts +227 -0
- package/src/identity/consumers.ts +53 -0
- package/src/identity/functions.ts +70 -0
- package/src/identity/identifiers.ts +82 -0
- package/src/identity/index.ts +10 -0
- package/src/identity/links.ts +280 -0
- package/src/identity/membership.ts +156 -0
- package/src/identity/principals.ts +301 -0
- package/src/identity/profiles-v2.ts +330 -0
- package/src/identity/profiles.ts +524 -0
- package/src/identity/return-targets.ts +20 -0
- package/src/identity/usernames.ts +101 -0
- package/src/identity/views.ts +289 -0
- package/src/immutable.ts +25 -0
- package/src/index.ts +7 -0
- package/src/oidc-continuation.ts +59 -0
- package/src/oidc-device-code.ts +401 -0
- package/src/oidc-rp.ts +2217 -0
- package/src/oidc-session-policy.ts +6 -0
- package/src/oidc-surface-server.ts +186 -0
- package/src/profile-form.css +1 -0
- package/src/profile-form.stylex.ts +226 -0
- package/src/profile-form.tsx +314 -0
- package/src/profile.ts +33 -0
- package/src/public-config.ts +294 -0
- package/src/public-profile-form-result.ts +82 -0
- package/src/public-profile-form.tsx +319 -0
- package/src/public-profile-links.ts +100 -0
- package/src/react.tsx +196 -0
- package/src/receipt-verifier.ts +273 -0
- package/src/registry.ts +600 -0
- package/src/urls.ts +234 -0
package/dist/urls.js
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// src/identity/consumers.ts
|
|
2
|
+
import { err, ok } from "@hraness/result";
|
|
3
|
+
|
|
4
|
+
// src/immutable.ts
|
|
5
|
+
function deepFreeze(value) {
|
|
6
|
+
const visited = new WeakSet;
|
|
7
|
+
function freezeOwned(current) {
|
|
8
|
+
if (current === null || typeof current !== "object")
|
|
9
|
+
return;
|
|
10
|
+
if (visited.has(current))
|
|
11
|
+
return;
|
|
12
|
+
visited.add(current);
|
|
13
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
14
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
15
|
+
if (descriptor !== undefined && "value" in descriptor) {
|
|
16
|
+
freezeOwned(descriptor.value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Object.freeze(current);
|
|
20
|
+
}
|
|
21
|
+
freezeOwned(value);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/identity/consumers.ts
|
|
26
|
+
var SUITE_CONSUMER_IDS = deepFreeze([
|
|
27
|
+
"accounts",
|
|
28
|
+
"act60",
|
|
29
|
+
"elders",
|
|
30
|
+
"soundfish",
|
|
31
|
+
"oh-computer",
|
|
32
|
+
"draw-money",
|
|
33
|
+
"oprte",
|
|
34
|
+
"sponge"
|
|
35
|
+
]);
|
|
36
|
+
var LEGACY_SUITE_CONSUMER_IDS = deepFreeze([
|
|
37
|
+
"kitchen"
|
|
38
|
+
]);
|
|
39
|
+
function parseSuiteConsumerId(value) {
|
|
40
|
+
switch (value) {
|
|
41
|
+
case "accounts":
|
|
42
|
+
case "act60":
|
|
43
|
+
case "elders":
|
|
44
|
+
case "soundfish":
|
|
45
|
+
case "oh-computer":
|
|
46
|
+
case "draw-money":
|
|
47
|
+
case "oprte":
|
|
48
|
+
case "sponge":
|
|
49
|
+
return ok(value);
|
|
50
|
+
case "kitchen":
|
|
51
|
+
return ok("oprte");
|
|
52
|
+
default:
|
|
53
|
+
return err("invalid-consumer");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/registry.ts
|
|
58
|
+
var SUITE_ACCOUNTS_REMOTE_ENVIRONMENTS = deepFreeze([
|
|
59
|
+
"production"
|
|
60
|
+
]);
|
|
61
|
+
var accountsCookies = deepFreeze({
|
|
62
|
+
chunked: ["account_data", "session_data"],
|
|
63
|
+
names: [
|
|
64
|
+
"account_data",
|
|
65
|
+
"convex_jwt",
|
|
66
|
+
"dont_remember",
|
|
67
|
+
"session_data",
|
|
68
|
+
"session_token"
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
var consumerCookies = deepFreeze({
|
|
72
|
+
chunked: ["session_data"],
|
|
73
|
+
names: ["dont_remember", "session_data", "session_token"]
|
|
74
|
+
});
|
|
75
|
+
var SUITE_ACCOUNTS_DEPLOYMENTS = deepFreeze({
|
|
76
|
+
production: {
|
|
77
|
+
accountsOrigin: "https://account.hraness.com",
|
|
78
|
+
convexSiteUrl: "https://qualified-marmot-22.convex.site",
|
|
79
|
+
convexUrl: "https://qualified-marmot-22.convex.cloud"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
function unsupported(siteUrl) {
|
|
83
|
+
return { billingReturn: { kind: "unsupported" }, siteUrl };
|
|
84
|
+
}
|
|
85
|
+
function oidcSite(id, displayName, productionSiteUrl) {
|
|
86
|
+
return {
|
|
87
|
+
auth: { basePath: "/api/suite-auth", kind: "oidc-rp" },
|
|
88
|
+
displayName,
|
|
89
|
+
environments: {
|
|
90
|
+
production: unsupported(productionSiteUrl)
|
|
91
|
+
},
|
|
92
|
+
id
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
var SUITE_ACCOUNTS_REGISTERED_CONSUMER_IDS = deepFreeze([
|
|
96
|
+
"accounts",
|
|
97
|
+
"act60",
|
|
98
|
+
"soundfish",
|
|
99
|
+
"oh-computer",
|
|
100
|
+
"draw-money",
|
|
101
|
+
"sponge"
|
|
102
|
+
]);
|
|
103
|
+
var SUITE_ACCOUNTS_CONSUMERS = deepFreeze({
|
|
104
|
+
accounts: {
|
|
105
|
+
auth: {
|
|
106
|
+
basePath: "/api/auth",
|
|
107
|
+
cookies: accountsCookies,
|
|
108
|
+
kind: "authority"
|
|
109
|
+
},
|
|
110
|
+
displayName: "Accounts",
|
|
111
|
+
environments: {
|
|
112
|
+
production: {
|
|
113
|
+
billingReturn: { kind: "supported", path: "/account" },
|
|
114
|
+
siteUrl: "https://account.hraness.com"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
id: "accounts"
|
|
118
|
+
},
|
|
119
|
+
act60: oidcSite("act60", "ACT60", "https://act60.me"),
|
|
120
|
+
soundfish: {
|
|
121
|
+
auth: { basePath: "/api/suite-auth", kind: "oidc-rp" },
|
|
122
|
+
displayName: "Soundfish",
|
|
123
|
+
environments: {
|
|
124
|
+
production: unsupported("https://sound.fish")
|
|
125
|
+
},
|
|
126
|
+
id: "soundfish"
|
|
127
|
+
},
|
|
128
|
+
"oh-computer": oidcSite("oh-computer", "Oh", "https://oh.computer"),
|
|
129
|
+
"draw-money": {
|
|
130
|
+
auth: {
|
|
131
|
+
basePath: "/api/auth",
|
|
132
|
+
cookies: consumerCookies,
|
|
133
|
+
kind: "proxy"
|
|
134
|
+
},
|
|
135
|
+
displayName: "Draw Money",
|
|
136
|
+
environments: {
|
|
137
|
+
production: unsupported("https://draw.money")
|
|
138
|
+
},
|
|
139
|
+
id: "draw-money"
|
|
140
|
+
},
|
|
141
|
+
sponge: oidcSite("sponge", "Sponge", "https://spongesearch.com")
|
|
142
|
+
});
|
|
143
|
+
var SUITE_ACCOUNTS_CURRENT_ORIGIN_OVERRIDES = deepFreeze({
|
|
144
|
+
sponge: {
|
|
145
|
+
production: unsupported("https://sponge.computer")
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
var SUITE_ACCOUNTS_CURRENT_CONSUMER_IDS = deepFreeze([
|
|
149
|
+
"accounts",
|
|
150
|
+
"act60",
|
|
151
|
+
"soundfish",
|
|
152
|
+
"oh-computer",
|
|
153
|
+
"sponge",
|
|
154
|
+
"peopleblade",
|
|
155
|
+
"aicharts",
|
|
156
|
+
"hraness",
|
|
157
|
+
"soulscrape",
|
|
158
|
+
"platonik",
|
|
159
|
+
"ghostget",
|
|
160
|
+
"alt",
|
|
161
|
+
"algal"
|
|
162
|
+
]);
|
|
163
|
+
function currentOidcSite(id, displayName, productionSiteUrl) {
|
|
164
|
+
return {
|
|
165
|
+
auth: { basePath: "/api/suite-auth", kind: "oidc-rp" },
|
|
166
|
+
displayName,
|
|
167
|
+
environments: {
|
|
168
|
+
production: unsupported(productionSiteUrl)
|
|
169
|
+
},
|
|
170
|
+
id
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
var SUITE_ACCOUNTS_CURRENT_CONSUMERS = deepFreeze({
|
|
174
|
+
accounts: SUITE_ACCOUNTS_CONSUMERS.accounts,
|
|
175
|
+
act60: SUITE_ACCOUNTS_CONSUMERS.act60,
|
|
176
|
+
soundfish: SUITE_ACCOUNTS_CONSUMERS.soundfish,
|
|
177
|
+
"oh-computer": SUITE_ACCOUNTS_CONSUMERS["oh-computer"],
|
|
178
|
+
sponge: currentOidcSite("sponge", "Sponge", SUITE_ACCOUNTS_CURRENT_ORIGIN_OVERRIDES.sponge.production.siteUrl),
|
|
179
|
+
peopleblade: currentOidcSite("peopleblade", "PeopleBlade", "https://peopleblade.com"),
|
|
180
|
+
aicharts: currentOidcSite("aicharts", "AI Charts", "https://aicharts.io"),
|
|
181
|
+
hraness: currentOidcSite("hraness", "Hraness", "https://hraness.com"),
|
|
182
|
+
soulscrape: currentOidcSite("soulscrape", "Soulscrape", "https://soulscrape.com"),
|
|
183
|
+
platonik: currentOidcSite("platonik", "Platonik", "https://platonik.space"),
|
|
184
|
+
ghostget: currentOidcSite("ghostget", "Ghostget", "https://ghostget.com"),
|
|
185
|
+
alt: currentOidcSite("alt", "Alt", "https://alt.dog"),
|
|
186
|
+
algal: currentOidcSite("algal", "Algal", "https://algal.cloud")
|
|
187
|
+
});
|
|
188
|
+
var SUITE_ACCOUNTS_ACTIVE_CONSUMER_IDS = deepFreeze([
|
|
189
|
+
"accounts",
|
|
190
|
+
"act60",
|
|
191
|
+
"soundfish",
|
|
192
|
+
"oh-computer",
|
|
193
|
+
"sponge"
|
|
194
|
+
]);
|
|
195
|
+
var SUITE_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS = deepFreeze(SUITE_ACCOUNTS_REGISTERED_CONSUMER_IDS.filter((consumer) => SUITE_ACCOUNTS_CONSUMERS[consumer].auth.kind === "oidc-rp"));
|
|
196
|
+
function suiteAccountsConsumerRequiresEmailOtp(consumer) {
|
|
197
|
+
return SUITE_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS.includes(consumer);
|
|
198
|
+
}
|
|
199
|
+
var SUITE_ACCOUNTS_LINKED_OIDC_CONSUMER_IDS = deepFreeze([
|
|
200
|
+
"soundfish"
|
|
201
|
+
]);
|
|
202
|
+
var SUITE_ACCOUNTS_CURRENT_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS = deepFreeze(SUITE_ACCOUNTS_CURRENT_CONSUMER_IDS.filter((consumer) => SUITE_ACCOUNTS_CURRENT_CONSUMERS[consumer].auth.kind === "oidc-rp"));
|
|
203
|
+
var SUITE_ACCOUNTS_CURRENT_LINKED_OIDC_CONSUMER_IDS = deepFreeze([
|
|
204
|
+
"soundfish",
|
|
205
|
+
"peopleblade",
|
|
206
|
+
"ghostget"
|
|
207
|
+
]);
|
|
208
|
+
var SUITE_ACCOUNTS_CURRENT_BROWSER_DEVICE_CODE_CONSUMER_IDS = deepFreeze([
|
|
209
|
+
"act60",
|
|
210
|
+
"soundfish",
|
|
211
|
+
"oh-computer",
|
|
212
|
+
"sponge",
|
|
213
|
+
"peopleblade",
|
|
214
|
+
"aicharts",
|
|
215
|
+
"hraness",
|
|
216
|
+
"soulscrape",
|
|
217
|
+
"platonik",
|
|
218
|
+
"ghostget",
|
|
219
|
+
"alt"
|
|
220
|
+
]);
|
|
221
|
+
var SUITE_ACCOUNTS_CURRENT_DEVICE_CLIENT_IDS = deepFreeze([
|
|
222
|
+
"algal-cli"
|
|
223
|
+
]);
|
|
224
|
+
var SUITE_ACCOUNTS_CURRENT_DEVICE_CLIENTS = deepFreeze({
|
|
225
|
+
"algal-cli": {
|
|
226
|
+
consumer: "algal",
|
|
227
|
+
displayName: "Algal CLI",
|
|
228
|
+
environments: ["production"],
|
|
229
|
+
id: "algal-cli"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
function isSuiteAccountsConsumerId(value) {
|
|
233
|
+
return typeof value === "string" && SUITE_CONSUMER_IDS.includes(value);
|
|
234
|
+
}
|
|
235
|
+
function isSuiteAccountsRegisteredConsumerId(value) {
|
|
236
|
+
return typeof value === "string" && SUITE_ACCOUNTS_REGISTERED_CONSUMER_IDS.includes(value);
|
|
237
|
+
}
|
|
238
|
+
function isSuiteAccountsOidcConsumerId(value) {
|
|
239
|
+
return isSuiteAccountsRegisteredConsumerId(value) && SUITE_ACCOUNTS_CONSUMERS[value].auth.kind === "oidc-rp";
|
|
240
|
+
}
|
|
241
|
+
function isSuiteAccountsLinkedOidcConsumerId(value) {
|
|
242
|
+
return SUITE_ACCOUNTS_LINKED_OIDC_CONSUMER_IDS.includes(value);
|
|
243
|
+
}
|
|
244
|
+
function isSuiteAccountsOAuthConsumerId(value) {
|
|
245
|
+
return isSuiteAccountsRegisteredConsumerId(value) && SUITE_ACCOUNTS_CONSUMERS[value].auth.kind === "oidc-rp";
|
|
246
|
+
}
|
|
247
|
+
function isSuiteAccountsCurrentConsumerId(value) {
|
|
248
|
+
return typeof value === "string" && SUITE_ACCOUNTS_CURRENT_CONSUMER_IDS.includes(value);
|
|
249
|
+
}
|
|
250
|
+
function isSuiteAccountsCurrentOidcConsumerId(value) {
|
|
251
|
+
return getSuiteAccountsCurrentConsumer(value).auth.kind === "oidc-rp";
|
|
252
|
+
}
|
|
253
|
+
function isSuiteAccountsCurrentLinkedOidcConsumerId(value) {
|
|
254
|
+
return SUITE_ACCOUNTS_CURRENT_LINKED_OIDC_CONSUMER_IDS.includes(value);
|
|
255
|
+
}
|
|
256
|
+
function isSuiteAccountsCurrentOAuthConsumerId(value) {
|
|
257
|
+
return getSuiteAccountsCurrentConsumer(value).auth.kind === "oidc-rp";
|
|
258
|
+
}
|
|
259
|
+
function isSuiteAccountsCurrentBrowserDeviceCodeConsumerId(value) {
|
|
260
|
+
return typeof value === "string" && SUITE_ACCOUNTS_CURRENT_BROWSER_DEVICE_CODE_CONSUMER_IDS.includes(value);
|
|
261
|
+
}
|
|
262
|
+
function isSuiteAccountsCurrentDeviceClientId(value) {
|
|
263
|
+
return typeof value === "string" && SUITE_ACCOUNTS_CURRENT_DEVICE_CLIENT_IDS.includes(value);
|
|
264
|
+
}
|
|
265
|
+
function suiteAccountsCurrentConsumerRequiresEmailOtp(consumer) {
|
|
266
|
+
return SUITE_ACCOUNTS_CURRENT_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS.includes(consumer);
|
|
267
|
+
}
|
|
268
|
+
function getSuiteAccountsConsumer(consumer) {
|
|
269
|
+
return SUITE_ACCOUNTS_CONSUMERS[consumer];
|
|
270
|
+
}
|
|
271
|
+
function getSuiteAccountsConsumerEnvironment(consumer, environment) {
|
|
272
|
+
if (!isSuiteAccountsRegisteredConsumerId(consumer))
|
|
273
|
+
return null;
|
|
274
|
+
const registration = getSuiteAccountsConsumer(consumer);
|
|
275
|
+
return registration.environments[environment] ?? null;
|
|
276
|
+
}
|
|
277
|
+
function getSuiteAccountsCurrentConsumer(consumer) {
|
|
278
|
+
return SUITE_ACCOUNTS_CURRENT_CONSUMERS[consumer];
|
|
279
|
+
}
|
|
280
|
+
function getSuiteAccountsCurrentConsumerEnvironment(consumer, environment) {
|
|
281
|
+
if (!isSuiteAccountsCurrentConsumerId(consumer))
|
|
282
|
+
return null;
|
|
283
|
+
return getSuiteAccountsCurrentConsumer(consumer).environments[environment] ?? null;
|
|
284
|
+
}
|
|
285
|
+
function isSuiteAccountsActiveConsumerId(value) {
|
|
286
|
+
return SUITE_ACCOUNTS_ACTIVE_CONSUMER_IDS.includes(value);
|
|
287
|
+
}
|
|
288
|
+
function getSuiteAccountsDeployment(environment) {
|
|
289
|
+
return SUITE_ACCOUNTS_DEPLOYMENTS[environment];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/urls.ts
|
|
293
|
+
var SUITE_ACCOUNTS_OAUTH_RESOURCE = "https://hraness.com/suite";
|
|
294
|
+
var CENTRAL_PATHS = deepFreeze({
|
|
295
|
+
account: "/account",
|
|
296
|
+
home: "/",
|
|
297
|
+
login: "/login"
|
|
298
|
+
});
|
|
299
|
+
function suiteAccountsCentralUrl(environment, destination) {
|
|
300
|
+
return new URL(CENTRAL_PATHS[destination], getSuiteAccountsDeployment(environment).accountsOrigin).href;
|
|
301
|
+
}
|
|
302
|
+
function suiteAccountsBillingReturnUrl(consumer, environment) {
|
|
303
|
+
const consumerEnvironment = getSuiteAccountsConsumerEnvironment(consumer, environment);
|
|
304
|
+
if (consumerEnvironment === null)
|
|
305
|
+
return null;
|
|
306
|
+
return consumerEnvironment.billingReturn.kind === "supported" ? new URL(consumerEnvironment.billingReturn.path, consumerEnvironment.siteUrl).href : null;
|
|
307
|
+
}
|
|
308
|
+
function suiteAccountsOidcClientRegistration(consumer, environment) {
|
|
309
|
+
if (!isSuiteAccountsConsumerId(consumer) || !isSuiteAccountsOAuthConsumerId(consumer))
|
|
310
|
+
return null;
|
|
311
|
+
const consumerEnvironment = getSuiteAccountsConsumerEnvironment(consumer, environment);
|
|
312
|
+
if (consumerEnvironment === null)
|
|
313
|
+
return null;
|
|
314
|
+
return deepFreeze({
|
|
315
|
+
callbackUrl: new URL("/api/suite-auth/callback", consumerEnvironment.siteUrl).href,
|
|
316
|
+
clientId: `hraness:${consumer}:${environment}:v1`
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function suiteAccountsCurrentOidcClientRegistration(consumer, environment) {
|
|
320
|
+
if (!isSuiteAccountsCurrentConsumerId(consumer) || !isSuiteAccountsCurrentOAuthConsumerId(consumer))
|
|
321
|
+
return null;
|
|
322
|
+
const consumerEnvironment = getSuiteAccountsCurrentConsumerEnvironment(consumer, environment);
|
|
323
|
+
if (consumerEnvironment === null)
|
|
324
|
+
return null;
|
|
325
|
+
return deepFreeze({
|
|
326
|
+
callbackUrl: new URL("/api/suite-auth/callback", consumerEnvironment.siteUrl).href,
|
|
327
|
+
clientId: `hraness:${consumer}:${environment}:v1`
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function suiteAccountsOidcClientRequiresEmailOtp(clientId) {
|
|
331
|
+
if (typeof clientId !== "string")
|
|
332
|
+
return false;
|
|
333
|
+
return SUITE_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS.some((consumer) => suiteAccountsOidcClientRegistration(consumer, "production")?.clientId === clientId);
|
|
334
|
+
}
|
|
335
|
+
function suiteAccountsCurrentOidcClientRequiresEmailOtp(clientId) {
|
|
336
|
+
if (typeof clientId !== "string")
|
|
337
|
+
return false;
|
|
338
|
+
return SUITE_ACCOUNTS_CURRENT_EMAIL_OTP_REQUIRED_OIDC_CONSUMER_IDS.some((consumer) => suiteAccountsCurrentOidcClientRegistration(consumer, "production")?.clientId === clientId);
|
|
339
|
+
}
|
|
340
|
+
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
341
|
+
function suiteAccountsCurrentDeviceClientRegistration(deviceClient, environment) {
|
|
342
|
+
if (!isSuiteAccountsCurrentDeviceClientId(deviceClient))
|
|
343
|
+
return null;
|
|
344
|
+
const registration = SUITE_ACCOUNTS_CURRENT_DEVICE_CLIENTS[deviceClient];
|
|
345
|
+
if (!registration.environments.includes(environment) || suiteAccountsCurrentOidcClientRegistration(registration.consumer, environment) === null) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
return deepFreeze({
|
|
349
|
+
clientId: `hraness:${deviceClient}:${environment}:v1`,
|
|
350
|
+
consumer: registration.consumer,
|
|
351
|
+
grantTypes: [DEVICE_CODE_GRANT_TYPE],
|
|
352
|
+
redirectUris: [],
|
|
353
|
+
scopes: ["openid", "email", "profile"],
|
|
354
|
+
tokenEndpointAuthMethod: "none"
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
function suiteAccountsCurrentDeviceCodeClientAllowed(clientId) {
|
|
358
|
+
if (typeof clientId !== "string")
|
|
359
|
+
return false;
|
|
360
|
+
return SUITE_ACCOUNTS_CURRENT_DEVICE_CLIENT_IDS.some((deviceClient) => suiteAccountsCurrentDeviceClientRegistration(deviceClient, "production")?.clientId === clientId) || SUITE_ACCOUNTS_CURRENT_BROWSER_DEVICE_CODE_CONSUMER_IDS.some((consumer) => isSuiteAccountsCurrentBrowserDeviceCodeConsumerId(consumer) && suiteAccountsCurrentOidcClientRegistration(consumer, "production")?.clientId === clientId);
|
|
361
|
+
}
|
|
362
|
+
function suiteAccountsOidcProviderConfiguration(environment) {
|
|
363
|
+
const issuer = getSuiteAccountsDeployment(environment).accountsOrigin;
|
|
364
|
+
const authBase = new URL("/api/auth/", issuer);
|
|
365
|
+
return deepFreeze({
|
|
366
|
+
authorizationEndpoint: new URL("oauth2/authorize", authBase).href,
|
|
367
|
+
deviceAuthorizationEndpoint: new URL("oauth2/device_authorization", authBase).href,
|
|
368
|
+
deviceTokenEndpoint: new URL("oauth2/device/token", authBase).href,
|
|
369
|
+
discoveryEndpoint: new URL("/.well-known/openid-configuration", issuer).href,
|
|
370
|
+
entitlementReceiptEndpoint: new URL("/suite/entitlements/receipt", issuer).href,
|
|
371
|
+
identityLinkReceiptEndpoint: new URL("/suite/identity-links/receipt", issuer).href,
|
|
372
|
+
issuer,
|
|
373
|
+
jwksEndpoint: new URL("jwks", authBase).href,
|
|
374
|
+
resource: SUITE_ACCOUNTS_OAUTH_RESOURCE,
|
|
375
|
+
revocationEndpoint: new URL("oauth2/revoke", authBase).href,
|
|
376
|
+
tokenEndpoint: new URL("oauth2/token", authBase).href,
|
|
377
|
+
userInfoAudience: new URL("oauth2/userinfo", authBase).href
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
export {
|
|
381
|
+
suiteAccountsOidcProviderConfiguration,
|
|
382
|
+
suiteAccountsOidcClientRequiresEmailOtp,
|
|
383
|
+
suiteAccountsOidcClientRegistration,
|
|
384
|
+
suiteAccountsCurrentOidcClientRequiresEmailOtp,
|
|
385
|
+
suiteAccountsCurrentOidcClientRegistration,
|
|
386
|
+
suiteAccountsCurrentDeviceCodeClientAllowed,
|
|
387
|
+
suiteAccountsCurrentDeviceClientRegistration,
|
|
388
|
+
suiteAccountsCentralUrl,
|
|
389
|
+
suiteAccountsBillingReturnUrl,
|
|
390
|
+
SUITE_ACCOUNTS_OAUTH_RESOURCE
|
|
391
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hraness/suite-accounts",
|
|
3
|
+
"version": "0.9.20",
|
|
4
|
+
"description": "Validated client and protocol boundaries for Hraness Accounts.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"./dist/auth-client.js",
|
|
9
|
+
"./dist/react.js",
|
|
10
|
+
"./src/profile-form.css",
|
|
11
|
+
"./dist/stylex.css",
|
|
12
|
+
"./compiler-foundation.css"
|
|
13
|
+
],
|
|
14
|
+
"packageManager": "bun@1.3.14",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/hraness/suite-accounts.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/hraness/suite-accounts#readme",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/hraness/suite-accounts/issues"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"accounts",
|
|
25
|
+
"authentication",
|
|
26
|
+
"oauth",
|
|
27
|
+
"oidc",
|
|
28
|
+
"pkce",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"bun": "./dist/index.js",
|
|
34
|
+
"types": "./src/index.ts",
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./auth-client": {
|
|
39
|
+
"bun": "./dist/auth-client.js",
|
|
40
|
+
"types": "./src/auth-client.ts",
|
|
41
|
+
"import": "./dist/auth-client.js",
|
|
42
|
+
"default": "./dist/auth-client.js"
|
|
43
|
+
},
|
|
44
|
+
"./auth-proxy": {
|
|
45
|
+
"bun": "./dist/auth-proxy.js",
|
|
46
|
+
"types": "./src/auth-proxy.ts",
|
|
47
|
+
"import": "./dist/auth-proxy.js",
|
|
48
|
+
"default": "./dist/auth-proxy.js"
|
|
49
|
+
},
|
|
50
|
+
"./bearer-verifier": {
|
|
51
|
+
"bun": "./dist/bearer-verifier.js",
|
|
52
|
+
"types": "./src/bearer-verifier.ts",
|
|
53
|
+
"import": "./dist/bearer-verifier.js",
|
|
54
|
+
"default": "./dist/bearer-verifier.js"
|
|
55
|
+
},
|
|
56
|
+
"./browser-session": {
|
|
57
|
+
"bun": "./dist/browser-session.js",
|
|
58
|
+
"types": "./src/browser-session.ts",
|
|
59
|
+
"import": "./dist/browser-session.js",
|
|
60
|
+
"default": "./dist/browser-session.js"
|
|
61
|
+
},
|
|
62
|
+
"./client-configuration": {
|
|
63
|
+
"bun": "./dist/client-configuration.js",
|
|
64
|
+
"types": "./src/client-configuration.ts",
|
|
65
|
+
"import": "./dist/client-configuration.js",
|
|
66
|
+
"default": "./dist/client-configuration.js"
|
|
67
|
+
},
|
|
68
|
+
"./convex-browser-auth": {
|
|
69
|
+
"bun": "./dist/convex-browser-auth.js",
|
|
70
|
+
"types": "./src/convex-browser-auth.ts",
|
|
71
|
+
"import": "./dist/convex-browser-auth.js",
|
|
72
|
+
"default": "./dist/convex-browser-auth.js"
|
|
73
|
+
},
|
|
74
|
+
"./convex-browser-auth-browser": {
|
|
75
|
+
"bun": "./dist/convex-browser-auth-browser.js",
|
|
76
|
+
"types": "./src/convex-browser-auth-browser.ts",
|
|
77
|
+
"import": "./dist/convex-browser-auth-browser.js",
|
|
78
|
+
"default": "./dist/convex-browser-auth-browser.js"
|
|
79
|
+
},
|
|
80
|
+
"./convex-browser-auth-server": {
|
|
81
|
+
"bun": "./dist/convex-browser-auth-server.js",
|
|
82
|
+
"types": "./src/convex-browser-auth-server.ts",
|
|
83
|
+
"import": "./dist/convex-browser-auth-server.js",
|
|
84
|
+
"default": "./dist/convex-browser-auth-server.js"
|
|
85
|
+
},
|
|
86
|
+
"./entitlements": {
|
|
87
|
+
"bun": "./dist/entitlements.js",
|
|
88
|
+
"types": "./src/entitlements.ts",
|
|
89
|
+
"import": "./dist/entitlements.js",
|
|
90
|
+
"default": "./dist/entitlements.js"
|
|
91
|
+
},
|
|
92
|
+
"./identity": {
|
|
93
|
+
"bun": "./dist/identity/index.js",
|
|
94
|
+
"types": "./src/identity/index.ts",
|
|
95
|
+
"import": "./dist/identity/index.js",
|
|
96
|
+
"default": "./dist/identity/index.js"
|
|
97
|
+
},
|
|
98
|
+
"./identity/functions": {
|
|
99
|
+
"bun": "./dist/identity/functions.js",
|
|
100
|
+
"types": "./src/identity/functions.ts",
|
|
101
|
+
"import": "./dist/identity/functions.js",
|
|
102
|
+
"default": "./dist/identity/functions.js"
|
|
103
|
+
},
|
|
104
|
+
"./identity/return-targets": {
|
|
105
|
+
"bun": "./dist/identity/return-targets.js",
|
|
106
|
+
"types": "./src/identity/return-targets.ts",
|
|
107
|
+
"import": "./dist/identity/return-targets.js",
|
|
108
|
+
"default": "./dist/identity/return-targets.js"
|
|
109
|
+
},
|
|
110
|
+
"./oidc-device-code": {
|
|
111
|
+
"bun": "./dist/oidc-device-code.js",
|
|
112
|
+
"types": "./src/oidc-device-code.ts",
|
|
113
|
+
"import": "./dist/oidc-device-code.js",
|
|
114
|
+
"default": "./dist/oidc-device-code.js"
|
|
115
|
+
},
|
|
116
|
+
"./oidc-rp": {
|
|
117
|
+
"bun": "./dist/oidc-rp.js",
|
|
118
|
+
"types": "./src/oidc-rp.ts",
|
|
119
|
+
"import": "./dist/oidc-rp.js",
|
|
120
|
+
"default": "./dist/oidc-rp.js"
|
|
121
|
+
},
|
|
122
|
+
"./oidc-session-policy": {
|
|
123
|
+
"bun": "./dist/oidc-session-policy.js",
|
|
124
|
+
"types": "./src/oidc-session-policy.ts",
|
|
125
|
+
"import": "./dist/oidc-session-policy.js",
|
|
126
|
+
"default": "./dist/oidc-session-policy.js"
|
|
127
|
+
},
|
|
128
|
+
"./oidc-surface-server": {
|
|
129
|
+
"bun": "./dist/oidc-surface-server.js",
|
|
130
|
+
"types": "./src/oidc-surface-server.ts",
|
|
131
|
+
"import": "./dist/oidc-surface-server.js",
|
|
132
|
+
"default": "./dist/oidc-surface-server.js"
|
|
133
|
+
},
|
|
134
|
+
"./profile": {
|
|
135
|
+
"bun": "./dist/profile.js",
|
|
136
|
+
"types": "./src/profile.ts",
|
|
137
|
+
"import": "./dist/profile.js",
|
|
138
|
+
"default": "./dist/profile.js"
|
|
139
|
+
},
|
|
140
|
+
"./profile-form": {
|
|
141
|
+
"bun": "./dist/profile-form.js",
|
|
142
|
+
"types": "./src/profile-form.tsx",
|
|
143
|
+
"import": "./dist/profile-form.js",
|
|
144
|
+
"default": "./dist/profile-form.js"
|
|
145
|
+
},
|
|
146
|
+
"./profile-form.css": "./src/profile-form.css",
|
|
147
|
+
"./stylex.css": "./dist/stylex.css",
|
|
148
|
+
"./stylex-manifest.json": "./dist/stylex-manifest.json",
|
|
149
|
+
"./compiler-foundation.css": "./compiler-foundation.css",
|
|
150
|
+
"./public-config": {
|
|
151
|
+
"bun": "./dist/public-config.js",
|
|
152
|
+
"types": "./src/public-config.ts",
|
|
153
|
+
"import": "./dist/public-config.js",
|
|
154
|
+
"default": "./dist/public-config.js"
|
|
155
|
+
},
|
|
156
|
+
"./react": {
|
|
157
|
+
"bun": "./dist/react.js",
|
|
158
|
+
"types": "./src/react.tsx",
|
|
159
|
+
"import": "./dist/react.js",
|
|
160
|
+
"default": "./dist/react.js"
|
|
161
|
+
},
|
|
162
|
+
"./receipt-verifier": {
|
|
163
|
+
"bun": "./dist/receipt-verifier.js",
|
|
164
|
+
"types": "./src/receipt-verifier.ts",
|
|
165
|
+
"import": "./dist/receipt-verifier.js",
|
|
166
|
+
"default": "./dist/receipt-verifier.js"
|
|
167
|
+
},
|
|
168
|
+
"./registry": {
|
|
169
|
+
"bun": "./dist/registry.js",
|
|
170
|
+
"types": "./src/registry.ts",
|
|
171
|
+
"import": "./dist/registry.js",
|
|
172
|
+
"default": "./dist/registry.js"
|
|
173
|
+
},
|
|
174
|
+
"./urls": {
|
|
175
|
+
"bun": "./dist/urls.js",
|
|
176
|
+
"types": "./src/urls.ts",
|
|
177
|
+
"import": "./dist/urls.js",
|
|
178
|
+
"default": "./dist/urls.js"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"main": "./dist/index.js",
|
|
182
|
+
"types": "./src/index.ts",
|
|
183
|
+
"files": [
|
|
184
|
+
"dist",
|
|
185
|
+
"src/**/*.ts",
|
|
186
|
+
"src/**/*.tsx",
|
|
187
|
+
"src/profile-form.css",
|
|
188
|
+
"compiler-foundation.css",
|
|
189
|
+
"!src/**/*.test.ts",
|
|
190
|
+
"!src/**/*.test.tsx",
|
|
191
|
+
"!src/**/*.property.test.ts",
|
|
192
|
+
"!src/test-support.ts",
|
|
193
|
+
"portfolio-inventory.json",
|
|
194
|
+
"README.md",
|
|
195
|
+
"LICENSE"
|
|
196
|
+
],
|
|
197
|
+
"scripts": {
|
|
198
|
+
"kb:refresh": "bunx --bun github:hraness/kb#v0.15.2 refresh --root kb",
|
|
199
|
+
"kb:check:lane": "bunx --bun github:hraness/kb#v0.15.2 check --root kb --no-catalog",
|
|
200
|
+
"kb:check": "bunx --bun github:hraness/kb#v0.15.2 check --root kb && bunx --bun github:hraness/kb#v0.15.2 agents check --root kb --repo .",
|
|
201
|
+
"kb:catalog": "bunx --bun github:hraness/kb#v0.15.2 catalog --root kb",
|
|
202
|
+
"build": "bun run ./scripts/build.ts",
|
|
203
|
+
"lint": "eslint src scripts",
|
|
204
|
+
"typecheck": "tsc --noEmit",
|
|
205
|
+
"test": "bun test --preload ./scripts/register-stylex-test-transform.ts ./src",
|
|
206
|
+
"test:property": "bun test ./src/*.property.test.ts ./src/identity/*.property.test.ts",
|
|
207
|
+
"test:package": "bun run ./scripts/package-smoke.ts",
|
|
208
|
+
"test:browser": "bun run test:browser:profile && bun run test:browser:public-profile && bun run test:browser:oidc",
|
|
209
|
+
"test:browser:oidc": "bun run ./scripts/oidc-navigation-browser.ts",
|
|
210
|
+
"test:browser:profile": "bun run ./scripts/profile-form-browser.ts",
|
|
211
|
+
"test:browser:public-profile": "bun run ./scripts/public-profile-form-browser.ts",
|
|
212
|
+
"check:stylex": "bun run ./scripts/check-stylex.ts",
|
|
213
|
+
"check:determinism": "bun run ./scripts/check-determinism.ts",
|
|
214
|
+
"check:portfolio-inventory": "bun run ./scripts/check-portfolio-inventory.ts",
|
|
215
|
+
"check:private-boundary": "bun run ./scripts/check-private-boundary.ts",
|
|
216
|
+
"check": "bun run check:portfolio-inventory && bun run lint && bun run typecheck && bun run test && bun run build && bun run check:stylex && bun run check:determinism && bun run check:private-boundary && bun run test:package",
|
|
217
|
+
"prepack": "bun run check"
|
|
218
|
+
},
|
|
219
|
+
"dependencies": {
|
|
220
|
+
"@convex-dev/better-auth": "0.12.5",
|
|
221
|
+
"@hraness/result": "github:hraness/result#17b311c0b31cf456777efc7d7f5fa1f1cafefe74",
|
|
222
|
+
"@stylexjs/stylex": "0.19.0",
|
|
223
|
+
"better-auth": "1.6.25",
|
|
224
|
+
"convex": "1.44.0",
|
|
225
|
+
"jose": "6.2.4"
|
|
226
|
+
},
|
|
227
|
+
"peerDependencies": {
|
|
228
|
+
"react": ">=18.3.1 <20",
|
|
229
|
+
"react-dom": ">=18.3.1 <20"
|
|
230
|
+
},
|
|
231
|
+
"peerDependenciesMeta": {
|
|
232
|
+
"react": {
|
|
233
|
+
"optional": true
|
|
234
|
+
},
|
|
235
|
+
"react-dom": {
|
|
236
|
+
"optional": true
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"devDependencies": {
|
|
240
|
+
"@babel/core": "7.29.7",
|
|
241
|
+
"@babel/plugin-syntax-jsx": "7.29.7",
|
|
242
|
+
"@babel/plugin-syntax-typescript": "7.29.7",
|
|
243
|
+
"@eslint/js": "^9.39.2",
|
|
244
|
+
"@hraness/ui": "github:hraness/ui#v0.5.12",
|
|
245
|
+
"@stylexjs/babel-plugin": "0.19.0",
|
|
246
|
+
"@types/babel__core": "7.20.5",
|
|
247
|
+
"@types/bun": "^1.3.14",
|
|
248
|
+
"@types/node": "^24.10.1",
|
|
249
|
+
"@types/react": "^19.2.14",
|
|
250
|
+
"@types/react-dom": "^19.2.3",
|
|
251
|
+
"eslint": "^9.39.2",
|
|
252
|
+
"fast-check": "^4.8.0",
|
|
253
|
+
"lightningcss": "1.33.0",
|
|
254
|
+
"playwright-core": "1.62.0",
|
|
255
|
+
"react": "19.2.3",
|
|
256
|
+
"react-dom": "19.2.3",
|
|
257
|
+
"typescript": "^6.0.3",
|
|
258
|
+
"typescript-eslint": "^8.53.0"
|
|
259
|
+
},
|
|
260
|
+
"publishConfig": {
|
|
261
|
+
"access": "public"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": "hraness.portfolio-inventory/v1",
|
|
3
|
+
"formatVersion": 1,
|
|
4
|
+
"repository": "hraness/suite-accounts",
|
|
5
|
+
"components": [
|
|
6
|
+
{
|
|
7
|
+
"kind": "package",
|
|
8
|
+
"name": "@hraness/suite-accounts",
|
|
9
|
+
"path": ".",
|
|
10
|
+
"visibility": "public",
|
|
11
|
+
"version": "0.9.20"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependencies": [
|
|
15
|
+
{
|
|
16
|
+
"from": "@hraness/suite-accounts",
|
|
17
|
+
"scope": "runtime",
|
|
18
|
+
"specifier": "github:hraness/result#17b311c0b31cf456777efc7d7f5fa1f1cafefe74",
|
|
19
|
+
"to": "@hraness/result"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"from": "@hraness/suite-accounts",
|
|
23
|
+
"scope": "development",
|
|
24
|
+
"specifier": "github:hraness/ui#v0.5.12",
|
|
25
|
+
"to": "@hraness/ui"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"deployments": [],
|
|
29
|
+
"brands": [],
|
|
30
|
+
"publications": [
|
|
31
|
+
{
|
|
32
|
+
"component": "@hraness/suite-accounts",
|
|
33
|
+
"packageName": "@hraness/suite-accounts",
|
|
34
|
+
"repository": "hraness/suite-accounts"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|