@flow-industries/id 0.26.2 → 0.26.4
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/README.md +38 -0
- package/contracts/v1/sdk-exports.json +30 -0
- package/dist/sdk/caller.d.ts +29 -0
- package/dist/sdk/caller.js +37 -0
- package/dist/sdk/client/atproto-resolver.d.ts +8 -0
- package/dist/sdk/client/atproto-resolver.js +87 -0
- package/dist/sdk/client/atproto.js +9 -1
- package/dist/sdk/client/create-flow.js +10 -0
- package/dist/sdk/client/index.d.ts +2 -1
- package/dist/sdk/client/index.js +1 -0
- package/dist/sdk/client/static-flow.js +2 -0
- package/dist/sdk/client/study-search.js +34 -4
- package/dist/sdk/db/invitations.d.ts +310 -0
- package/dist/sdk/db/invitations.js +42 -0
- package/dist/sdk/db/schema.d.ts +248 -0
- package/dist/sdk/db/schema.js +25 -0
- package/dist/sdk/session-view.d.ts +15 -0
- package/dist/sdk/session-view.js +32 -0
- package/dist/sdk/types/atproto-resolver.d.ts +46 -0
- package/dist/sdk/types/atproto-resolver.js +0 -0
- package/dist/sdk/types/atproto.d.ts +22 -0
- package/dist/sdk/types/auth.d.ts +4 -0
- package/dist/sdk/types/dialog.d.ts +3 -0
- package/dist/sdk/types/hosted-oauth.d.ts +23 -0
- package/dist/sdk/types/hosted-oauth.js +0 -0
- package/dist/sdk/types/hosting-quota.d.ts +28 -0
- package/dist/sdk/types/hosting-quota.js +0 -0
- package/dist/sdk/types/index.d.ts +5 -1
- package/dist/sdk/types/managed-provisioning.d.ts +51 -0
- package/dist/sdk/types/managed-provisioning.js +0 -0
- package/dist/sdk/types/sdk.d.ts +2 -0
- package/package.json +4 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Context } from "hono";
|
|
2
|
+
import type { Caller } from "../caller";
|
|
3
|
+
import type { AtprotoResolution } from "./atproto";
|
|
4
|
+
import type { ManagedPdsState } from "./managed-provisioning";
|
|
5
|
+
export type AtprotoMapping = Pick<AtprotoResolution, "flowUserId" | "did" | "identityVersion" | "lifecycle">;
|
|
6
|
+
export type DidDocumentInput = {
|
|
7
|
+
id: string;
|
|
8
|
+
service?: unknown[];
|
|
9
|
+
};
|
|
10
|
+
export type AtprotoResolverDeps = {
|
|
11
|
+
testOrigin?: string;
|
|
12
|
+
resolveIdentity: (did: string, options: {
|
|
13
|
+
noCache: boolean;
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
}) => Promise<{
|
|
16
|
+
did: string;
|
|
17
|
+
didDoc: DidDocumentInput;
|
|
18
|
+
handle: string;
|
|
19
|
+
}>;
|
|
20
|
+
assertPublicEndpoint: (endpoint: string) => Promise<void>;
|
|
21
|
+
authorization: (did: string, endpoint: string, signal: AbortSignal) => Promise<AtprotoResolution["authorization"]>;
|
|
22
|
+
flowPdsOrigins: ReadonlySet<string>;
|
|
23
|
+
ttlMs: number;
|
|
24
|
+
now?: () => number;
|
|
25
|
+
};
|
|
26
|
+
export type ManagedResolverState = {
|
|
27
|
+
lifecycle: ManagedPdsState;
|
|
28
|
+
identityVersion: number;
|
|
29
|
+
};
|
|
30
|
+
export type AtprotoResolverRouteDeps = {
|
|
31
|
+
admit: (userId: string) => Promise<boolean>;
|
|
32
|
+
resolveCaller: (context: Context) => Promise<Caller | null>;
|
|
33
|
+
activeAccountOf?: (headers: Headers) => Promise<string | null | undefined>;
|
|
34
|
+
readMapping: (userId: string) => Promise<AtprotoMapping>;
|
|
35
|
+
resolve: (mapping: AtprotoMapping, freshness: "cached" | "refresh", signal?: AbortSignal) => Promise<AtprotoResolution>;
|
|
36
|
+
};
|
|
37
|
+
export type AtprotoResolverAdmissionCaps = {
|
|
38
|
+
userHourly: number;
|
|
39
|
+
globalHourly: number;
|
|
40
|
+
};
|
|
41
|
+
export type AtprotoStoredGrant = {
|
|
42
|
+
sub: string;
|
|
43
|
+
aud: string;
|
|
44
|
+
iss: string;
|
|
45
|
+
expires_at?: string;
|
|
46
|
+
};
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type AtprotoStartRequest = {
|
|
2
2
|
identifier: string;
|
|
3
|
+
invitationCode?: string;
|
|
3
4
|
intent: "login" | "link";
|
|
4
5
|
transaction?: string;
|
|
5
6
|
expectedUserId?: string;
|
|
@@ -23,3 +24,24 @@ export type AtprotoStatus = {
|
|
|
23
24
|
canUnlink: boolean;
|
|
24
25
|
unlinkBlockReason: string | null;
|
|
25
26
|
};
|
|
27
|
+
export type AtprotoResolutionFailure = "SIGN_IN_REQUIRED" | "NO_AT_IDENTITY" | "PROVISIONING_PENDING" | "PROVISIONING_FAILED" | "ACCOUNT_CHANGED" | "UNSUPPORTED_DID_METHOD" | "IDENTITY_INVALID" | "RESOLUTION_UNAVAILABLE";
|
|
28
|
+
export type AtprotoResolution = {
|
|
29
|
+
flowUserId: string;
|
|
30
|
+
did: string;
|
|
31
|
+
handle: string | null;
|
|
32
|
+
pdsUrl: string;
|
|
33
|
+
hosting: "flow" | "external";
|
|
34
|
+
lifecycle: "active" | "suspended" | "migrated" | "deletion_pending";
|
|
35
|
+
authorization: "connected" | "reconnect_required";
|
|
36
|
+
resolvedAt: string;
|
|
37
|
+
expiresAt: string;
|
|
38
|
+
identityVersion: string;
|
|
39
|
+
};
|
|
40
|
+
export type AtprotoResolveOptions = {
|
|
41
|
+
freshness?: "cached" | "refresh";
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
};
|
|
44
|
+
export type AtprotoApi = {
|
|
45
|
+
resolve(options?: AtprotoResolveOptions): Promise<AtprotoResolution>;
|
|
46
|
+
invalidate(): void;
|
|
47
|
+
};
|
package/dist/sdk/types/auth.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { JWTPayload } from "jose";
|
|
2
2
|
import type { AuthEventName } from "./events";
|
|
3
|
+
import type { ManagedPdsEnrollment } from "./managed-provisioning";
|
|
3
4
|
export type FlowUser = {
|
|
4
5
|
id: string;
|
|
5
6
|
username: string;
|
|
@@ -74,6 +75,7 @@ export type AuthResponse = {
|
|
|
74
75
|
additionalSessions?: AdditionalSession[];
|
|
75
76
|
};
|
|
76
77
|
export type AuthConfig = {
|
|
78
|
+
managedPdsEnabled?: boolean;
|
|
77
79
|
atprotoEnabled?: boolean;
|
|
78
80
|
rpId: string;
|
|
79
81
|
rpName: string;
|
|
@@ -96,6 +98,7 @@ export type AuthResponseWithWebAuthn = AuthResponse & {
|
|
|
96
98
|
export type PasskeyPluginOptions = {
|
|
97
99
|
rpId: string;
|
|
98
100
|
rpName?: string;
|
|
101
|
+
enrollManagedPds?: ManagedPdsEnrollment;
|
|
99
102
|
};
|
|
100
103
|
export type VerifyOptions = {
|
|
101
104
|
audience: string;
|
|
@@ -169,6 +172,7 @@ export type PasskeyEnrollment = {
|
|
|
169
172
|
credential: FlowCredential;
|
|
170
173
|
};
|
|
171
174
|
export type AccountRegistration = {
|
|
175
|
+
invitationCode?: string;
|
|
172
176
|
username: string;
|
|
173
177
|
email: string;
|
|
174
178
|
subscribedToNews: boolean;
|
|
@@ -90,6 +90,9 @@ export type DialogState = {
|
|
|
90
90
|
customLabels?: DialogCustomLabels;
|
|
91
91
|
};
|
|
92
92
|
export type SignUpProps = {
|
|
93
|
+
managedPdsEnabled?: boolean;
|
|
94
|
+
invitationCode?: string;
|
|
95
|
+
invitation?: import("react").ReactNode;
|
|
93
96
|
verifiedEmail?: {
|
|
94
97
|
email: string;
|
|
95
98
|
nonce: string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AppDb } from "../db/handle";
|
|
2
|
+
export interface HostedOAuthTransaction {
|
|
3
|
+
issuer: string;
|
|
4
|
+
pds: string;
|
|
5
|
+
requestUri: string;
|
|
6
|
+
deviceId: string;
|
|
7
|
+
clientId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HostedOAuthMapping {
|
|
10
|
+
did: string;
|
|
11
|
+
pds: string;
|
|
12
|
+
version: string;
|
|
13
|
+
}
|
|
14
|
+
/** Called under the canonical user lock; returns only active managed identities. */
|
|
15
|
+
export type HostedOAuthMappingReader = (database: AppDb, userId: string) => Promise<HostedOAuthMapping | null>;
|
|
16
|
+
export interface HostedOAuthProofOptions {
|
|
17
|
+
testOrigin?: string;
|
|
18
|
+
issuer: string;
|
|
19
|
+
pds: string;
|
|
20
|
+
lifetimeMs: number;
|
|
21
|
+
maximumPendingProofs: number;
|
|
22
|
+
readMapping: HostedOAuthMappingReader;
|
|
23
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface HostingQuotaPolicy {
|
|
2
|
+
totalBytes: number;
|
|
3
|
+
uploadBytes: number;
|
|
4
|
+
scratchBytes: number;
|
|
5
|
+
concurrentUploads: number;
|
|
6
|
+
}
|
|
7
|
+
export interface HostingQuotaReservation {
|
|
8
|
+
bytes: number;
|
|
9
|
+
fence: number;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
state: "active" | "cleanup";
|
|
12
|
+
}
|
|
13
|
+
export interface HostingQuotaLedger {
|
|
14
|
+
revision: number;
|
|
15
|
+
nextFence: number;
|
|
16
|
+
certain: boolean;
|
|
17
|
+
recordBytes: number;
|
|
18
|
+
blobs: Record<string, number>;
|
|
19
|
+
deletionDebt: Record<string, {
|
|
20
|
+
bytes: number;
|
|
21
|
+
fence: number;
|
|
22
|
+
}>;
|
|
23
|
+
reservations: Record<string, HostingQuotaReservation>;
|
|
24
|
+
}
|
|
25
|
+
export interface HostingQuotaAdmission {
|
|
26
|
+
ledger: HostingQuotaLedger;
|
|
27
|
+
fence: number;
|
|
28
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { AccountDeleteRequest, AccountDeleteResponse, AccountErasureCounts, AccountErasureEntry, AccountErasureFeed, AccountErasureResult, AccountExport, AccountExportAccount, AccountExportActionEvent, AccountExportActionSession, AccountExportAttendance, AccountExportAuthoredEvent, AccountExportCharacterStateTime, AccountExportFollow, AccountExportGameEvent, AccountExportNotification, AccountExportOtherService, AccountExportOwnedRoom, AccountExportPasskey, AccountExportRoomEvents, AccountExportRoomMembership, AccountExportRoomPlayerState, AccountExportRoomPresence, AccountExportRoomRestriction, AccountExportRoomSettings, AccountExportRooms, AccountExportRsvp, AccountExportSettingsSurface, AccountExportStudySubject, AccountExportXpGrant, AccountExportXpSummary, } from "./account-data";
|
|
2
2
|
export type { ActionCurve, ActionEventRequest, ActionEventResponse, ActionsApi, ActiveActionState, FinishActionRequest, ListStudySessionsOptions, ListStudySubjectsOptions, StartActionInput, StartActionResult, StudyApi, StudySubjectResponse, UseActiveActionOptions, XpEstimateContext, } from "./actions";
|
|
3
|
-
export type { AtprotoCompletion, AtprotoStartRequest, AtprotoStatus, } from "./atproto";
|
|
3
|
+
export type { AtprotoApi, AtprotoCompletion, AtprotoResolution, AtprotoResolutionFailure, AtprotoResolveOptions, AtprotoStartRequest, AtprotoStatus, } from "./atproto";
|
|
4
|
+
export type { AtprotoMapping, AtprotoResolverAdmissionCaps, AtprotoResolverDeps, AtprotoResolverRouteDeps, AtprotoStoredGrant, DidDocumentInput, ManagedResolverState, } from "./atproto-resolver";
|
|
4
5
|
export type { AccountRegistration, AccountSession, AccountSessionsResponse, AdditionalSession, AuthConfig, AuthorizationTransaction, AuthPageBootstrap, AuthResponse, AuthResponseWithWebAuthn, BioNormalization, BioRejection, BioWriteRefusal, BioWriteResult, FlowCredential, FlowUser, PasskeyEnrollment, PasskeyPluginOptions, RevokeAllSessionsResponse, RevokeSessionResponse, SecurityActivityEntry, SecurityActivityResponse, SessionUser, VerifiedFlowJWT, VerifyOptions, WebAuthnSignature, } from "./auth";
|
|
5
6
|
export type { BrowserAccount, BrowserAccounts } from "./browser-accounts";
|
|
6
7
|
export type { BodyRegion, CosmeticItem, CosmeticMaterial, CosmeticPaint, CosmeticSlot, EquipConflict, EquippedCosmetic, EquippedCosmetics, EquipRegion, PaintSlot, SettingsConflict, } from "./cosmetics";
|
|
@@ -10,7 +11,10 @@ export type { AuthErrorCode, AuthEventName, AuthEventRecord, AuthMode, AuthOutco
|
|
|
10
11
|
export type { ActiveAction, CatalogFieldRef, ClockAnchor, FinishedSummary, FocusApi, FocusPhase, FocusSessionEvent, FocusSessionState, StartFocusRequest, StudySearchHit, } from "./focus";
|
|
11
12
|
export type { GameEventReport, GameLifecycleEventName, GameLifecycleFeedEvent, GameLifecycleFeedPage, GamePlayerSession, } from "./game";
|
|
12
13
|
export { GAME_LIFECYCLE_EVENT_NAMES } from "./game";
|
|
14
|
+
export type { HostedOAuthMapping, HostedOAuthMappingReader, HostedOAuthProofOptions, HostedOAuthTransaction, } from "./hosted-oauth";
|
|
15
|
+
export type { HostingQuotaAdmission, HostingQuotaLedger, HostingQuotaPolicy, HostingQuotaReservation, } from "./hosting-quota";
|
|
13
16
|
export type { AccountProfileData } from "./landing";
|
|
17
|
+
export type * from "./managed-provisioning";
|
|
14
18
|
export type { Bridge, BridgeParameters, FlowAccount, FlowRemote, FlowRemoteConfig, FromWindowOptions, MessageResponse, Messenger, OneOf, Payload, QueuedRequest, ReadyOptions, RemoteFlowState, RemoteState, Schema, Storage, Topic, WithReady, } from "./messenger";
|
|
15
19
|
export type { MarkNotificationsReadInput, NotificationCounts, NotificationEntry, NotificationPage, NotificationReadResult, NotificationRefusal, } from "./notifications";
|
|
16
20
|
export type { OtpVerificationFailure, OtpVerificationResult, VerificationAdapter, } from "./otp";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AppDb } from "../db/handle";
|
|
2
|
+
/** Queues a reservation in the enrollment transaction; remote provisioning runs after commit. */
|
|
3
|
+
export type ManagedPdsEnrollment = (database: AppDb, userId: string) => Promise<void>;
|
|
4
|
+
export type ManagedPdsState = "queued" | "provisioning" | "active" | "failed" | "suspended" | "migrated" | "deletion_pending";
|
|
5
|
+
export interface ManagedPdsReservation {
|
|
6
|
+
operationId: string;
|
|
7
|
+
handle: string;
|
|
8
|
+
pdsEndpoint: string;
|
|
9
|
+
inviteReference: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ManagedPdsIdentity {
|
|
12
|
+
did: string;
|
|
13
|
+
handle: string;
|
|
14
|
+
pdsEndpoint: string;
|
|
15
|
+
}
|
|
16
|
+
export type ManagedPdsRecovery = {
|
|
17
|
+
outcome: "committed";
|
|
18
|
+
identity: ManagedPdsIdentity;
|
|
19
|
+
} | {
|
|
20
|
+
outcome: "absent";
|
|
21
|
+
} | {
|
|
22
|
+
outcome: "pending";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Server-only adapter for an authenticated operator API. It must durably bind
|
|
26
|
+
* operationId to key material before PLC publication and replay the same DID
|
|
27
|
+
* through every crash boundary. Stock createAccount does not implement this.
|
|
28
|
+
*/
|
|
29
|
+
export interface ManagedPdsProvisioner {
|
|
30
|
+
contract: "durable-operation-idempotency-v1";
|
|
31
|
+
remove?(reservation: ManagedPdsReservation & {
|
|
32
|
+
did: string | null;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
recover(reservation: ManagedPdsReservation): Promise<ManagedPdsRecovery>;
|
|
35
|
+
create(reservation: ManagedPdsReservation): Promise<ManagedPdsIdentity>;
|
|
36
|
+
}
|
|
37
|
+
export interface ManagedPdsWorkerLimits {
|
|
38
|
+
leaseMs: number;
|
|
39
|
+
maxAttempts: number;
|
|
40
|
+
}
|
|
41
|
+
export type ManagedPdsConfig = {
|
|
42
|
+
endpoint: string;
|
|
43
|
+
operatorEndpoint: string;
|
|
44
|
+
operatorToken: string;
|
|
45
|
+
};
|
|
46
|
+
export interface ManagedPdsTickReport {
|
|
47
|
+
active: number;
|
|
48
|
+
failed: number;
|
|
49
|
+
idle: number;
|
|
50
|
+
deleted?: number;
|
|
51
|
+
}
|
|
File without changes
|
package/dist/sdk/types/sdk.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { Chain, Hex, PrepareTransactionRequestParameters, SendTransactionParameters, SignTypedDataParameters, Transport, WalletClient } from "viem";
|
|
3
3
|
import type { SendCallsParameters } from "viem/actions";
|
|
4
4
|
import type { RawValue } from "../json";
|
|
5
|
+
import type { AtprotoApi } from "./atproto";
|
|
5
6
|
import type { AdditionalSession, FlowCredential, FlowUser, WebAuthnSignature } from "./auth";
|
|
6
7
|
import type { BrowserAccount, BrowserAccounts } from "./browser-accounts";
|
|
7
8
|
import type { ConnectCapabilities } from "./protocol";
|
|
@@ -377,6 +378,7 @@ export type Flow = {
|
|
|
377
378
|
}): Promise<WalletClient>;
|
|
378
379
|
/** Typed client for the room registry (browse, membership, settings, moderation). */
|
|
379
380
|
rooms: RoomsApi;
|
|
381
|
+
atproto: AtprotoApi;
|
|
380
382
|
subscribe(listener: Listener<FlowState>): () => void;
|
|
381
383
|
getState(): FlowState;
|
|
382
384
|
dialog: DialogHost;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flow-industries/id",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"prepublishOnly": "bun run build:sdk",
|
|
77
77
|
"start": "bun run src/index.ts",
|
|
78
78
|
"worker": "bun run src/worker.ts",
|
|
79
|
+
"worker:managed-pds": "bun run src/managed-pds-worker.ts",
|
|
79
80
|
"db:generate": "bunx @better-auth/cli generate",
|
|
80
81
|
"db:migrate:gen": "bunx drizzle-kit generate",
|
|
81
82
|
"db:migrate": "bun scripts/db-migrate.ts",
|
|
@@ -149,10 +150,11 @@
|
|
|
149
150
|
],
|
|
150
151
|
"dependencies": {
|
|
151
152
|
"@atproto-labs/handle-resolver": "^0.4.9",
|
|
153
|
+
"@atproto-labs/identity-resolver": "0.4.9",
|
|
152
154
|
"@atproto/jwk-jose": "^0.2.4",
|
|
153
155
|
"@atproto/oauth-client": "^0.8.7",
|
|
154
156
|
"@aws-sdk/client-s3": "^3.1073.0",
|
|
155
|
-
"@flow-industries/ui": "
|
|
157
|
+
"@flow-industries/ui": "0.23.4",
|
|
156
158
|
"@hono/otel": "^1.1.2",
|
|
157
159
|
"@openobserve/browser-logs": "^0.3.1",
|
|
158
160
|
"@openobserve/browser-rum": "^0.3.1",
|