@hypercerts-org/sdk-core 0.8.0-beta.0 → 0.10.0-beta.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/index.d.ts CHANGED
@@ -1179,13 +1179,13 @@ interface CreateHypercertParams {
1179
1179
  *
1180
1180
  * ISO 8601 date format (YYYY-MM-DD).
1181
1181
  */
1182
- workTimeframeFrom: string;
1182
+ workTimeFrameFrom: string;
1183
1183
  /**
1184
1184
  * End date of the work period.
1185
1185
  *
1186
1186
  * ISO 8601 date format (YYYY-MM-DD).
1187
1187
  */
1188
- workTimeframeTo: string;
1188
+ workTimeFrameTo: string;
1189
1189
  /**
1190
1190
  * Rights associated with the hypercert.
1191
1191
  */
@@ -1210,11 +1210,11 @@ interface CreateHypercertParams {
1210
1210
  description: string;
1211
1211
  };
1212
1212
  /**
1213
- * Optional short description for display in lists/cards.
1213
+ * Short description for display in lists/cards.
1214
1214
  *
1215
- * Should be under 200 characters.
1215
+ * Required field. Should be under 300 characters.
1216
1216
  */
1217
- shortDescription?: string;
1217
+ shortDescription: string;
1218
1218
  /**
1219
1219
  * Optional cover image for the hypercert.
1220
1220
  *
@@ -2355,7 +2355,32 @@ declare const OAuthConfigSchema: z.ZodObject<{
2355
2355
  redirectUri: z.ZodString;
2356
2356
  /**
2357
2357
  * OAuth scopes to request, space-separated.
2358
- * Common scopes: "atproto", "transition:generic"
2358
+ *
2359
+ * Can be a string of space-separated permissions or use the permission system:
2360
+ *
2361
+ * @example Using presets
2362
+ * ```typescript
2363
+ * import { ScopePresets } from '@hypercerts-org/sdk-core';
2364
+ * scope: ScopePresets.EMAIL_AND_PROFILE
2365
+ * ```
2366
+ *
2367
+ * @example Building custom scopes
2368
+ * ```typescript
2369
+ * import { PermissionBuilder, buildScope } from '@hypercerts-org/sdk-core';
2370
+ * scope: buildScope(
2371
+ * new PermissionBuilder()
2372
+ * .accountEmail('read')
2373
+ * .repoWrite('app.bsky.feed.post')
2374
+ * .build()
2375
+ * )
2376
+ * ```
2377
+ *
2378
+ * @example Legacy scopes
2379
+ * ```typescript
2380
+ * scope: "atproto transition:generic"
2381
+ * ```
2382
+ *
2383
+ * @see https://atproto.com/specs/permission for permission details
2359
2384
  */
2360
2385
  scope: z.ZodString;
2361
2386
  /**
@@ -2461,7 +2486,32 @@ declare const ATProtoSDKConfigSchema: z.ZodObject<{
2461
2486
  redirectUri: z.ZodString;
2462
2487
  /**
2463
2488
  * OAuth scopes to request, space-separated.
2464
- * Common scopes: "atproto", "transition:generic"
2489
+ *
2490
+ * Can be a string of space-separated permissions or use the permission system:
2491
+ *
2492
+ * @example Using presets
2493
+ * ```typescript
2494
+ * import { ScopePresets } from '@hypercerts-org/sdk-core';
2495
+ * scope: ScopePresets.EMAIL_AND_PROFILE
2496
+ * ```
2497
+ *
2498
+ * @example Building custom scopes
2499
+ * ```typescript
2500
+ * import { PermissionBuilder, buildScope } from '@hypercerts-org/sdk-core';
2501
+ * scope: buildScope(
2502
+ * new PermissionBuilder()
2503
+ * .accountEmail('read')
2504
+ * .repoWrite('app.bsky.feed.post')
2505
+ * .build()
2506
+ * )
2507
+ * ```
2508
+ *
2509
+ * @example Legacy scopes
2510
+ * ```typescript
2511
+ * scope: "atproto transition:generic"
2512
+ * ```
2513
+ *
2514
+ * @see https://atproto.com/specs/permission for permission details
2465
2515
  */
2466
2516
  scope: z.ZodString;
2467
2517
  /**
@@ -2703,13 +2753,47 @@ interface AuthorizeOptions {
2703
2753
  * OAuth scope string to request specific permissions.
2704
2754
  * Overrides the default scope configured in {@link ATProtoSDKConfig.oauth.scope}.
2705
2755
  *
2706
- * @example
2756
+ * Can use the permission system for type-safe scope building.
2757
+ *
2758
+ * @example Using presets
2759
+ * ```typescript
2760
+ * import { ScopePresets } from '@hypercerts-org/sdk-core';
2761
+ *
2762
+ * // Request email and profile access
2763
+ * await sdk.authorize("user.bsky.social", {
2764
+ * scope: ScopePresets.EMAIL_AND_PROFILE
2765
+ * });
2766
+ *
2767
+ * // Request full posting capabilities
2768
+ * await sdk.authorize("user.bsky.social", {
2769
+ * scope: ScopePresets.POSTING_APP
2770
+ * });
2771
+ * ```
2772
+ *
2773
+ * @example Building custom scopes
2774
+ * ```typescript
2775
+ * import { PermissionBuilder, buildScope } from '@hypercerts-org/sdk-core';
2776
+ *
2777
+ * const scope = buildScope(
2778
+ * new PermissionBuilder()
2779
+ * .accountEmail('read')
2780
+ * .repoWrite('app.bsky.feed.post')
2781
+ * .blob(['image/*'])
2782
+ * .build()
2783
+ * );
2784
+ *
2785
+ * await sdk.authorize("user.bsky.social", { scope });
2786
+ * ```
2787
+ *
2788
+ * @example Legacy scopes
2707
2789
  * ```typescript
2708
2790
  * // Request read-only access
2709
2791
  * await sdk.authorize("user.bsky.social", { scope: "atproto" });
2710
2792
  *
2711
- * // Request full access (default typically includes transition:generic)
2712
- * await sdk.authorize("user.bsky.social", { scope: "atproto transition:generic" });
2793
+ * // Request full access (legacy)
2794
+ * await sdk.authorize("user.bsky.social", {
2795
+ * scope: "atproto transition:generic"
2796
+ * });
2713
2797
  * ```
2714
2798
  */
2715
2799
  scope?: string;
@@ -2902,6 +2986,56 @@ declare class ATProtoSDK {
2902
2986
  * ```
2903
2987
  */
2904
2988
  revokeSession(did: string): Promise<void>;
2989
+ /**
2990
+ * Gets the account email address from the authenticated session.
2991
+ *
2992
+ * This method retrieves the email address associated with the user's account
2993
+ * by calling the `com.atproto.server.getSession` endpoint. The email will only
2994
+ * be returned if the appropriate OAuth scope was granted during authorization.
2995
+ *
2996
+ * Required OAuth scopes:
2997
+ * - **Granular permissions**: `account:email?action=read` or `account:email`
2998
+ * - **Transitional permissions**: `transition:email`
2999
+ *
3000
+ * @param session - An authenticated OAuth session
3001
+ * @returns A Promise resolving to email info, or `null` if permission not granted
3002
+ * @throws {@link ValidationError} if the session is invalid
3003
+ * @throws {@link NetworkError} if the API request fails
3004
+ *
3005
+ * @example Using granular permissions
3006
+ * ```typescript
3007
+ * import { ScopePresets } from '@hypercerts-org/sdk-core';
3008
+ *
3009
+ * // Authorize with email scope
3010
+ * const authUrl = await sdk.authorize("user.bsky.social", {
3011
+ * scope: ScopePresets.EMAIL_READ
3012
+ * });
3013
+ *
3014
+ * // After callback...
3015
+ * const emailInfo = await sdk.getAccountEmail(session);
3016
+ * if (emailInfo) {
3017
+ * console.log(`Email: ${emailInfo.email}`);
3018
+ * console.log(`Confirmed: ${emailInfo.emailConfirmed}`);
3019
+ * } else {
3020
+ * console.log("Email permission not granted");
3021
+ * }
3022
+ * ```
3023
+ *
3024
+ * @example Using transitional permissions (legacy)
3025
+ * ```typescript
3026
+ * // Authorize with transition:email scope
3027
+ * const authUrl = await sdk.authorize("user.bsky.social", {
3028
+ * scope: "atproto transition:email"
3029
+ * });
3030
+ *
3031
+ * // After callback...
3032
+ * const emailInfo = await sdk.getAccountEmail(session);
3033
+ * ```
3034
+ */
3035
+ getAccountEmail(session: Session): Promise<{
3036
+ email: string;
3037
+ emailConfirmed: boolean;
3038
+ } | null>;
2905
3039
  /**
2906
3040
  * Creates a repository instance for data operations.
2907
3041
  *
@@ -3532,5 +3666,1047 @@ declare class InMemoryStateStore implements StateStore {
3532
3666
  clear(): void;
3533
3667
  }
3534
3668
 
3535
- export { ATProtoSDK, ATProtoSDKConfigSchema, ATProtoSDKError, AuthenticationError, CollaboratorPermissionsSchema, CollaboratorSchema, ConfigurableAgent, InMemorySessionStore, InMemoryStateStore, LexiconRegistry, NetworkError, OAuthConfigSchema, OrganizationSchema, Repository, SDSRequiredError, ServerConfigSchema, SessionExpiredError, TimeoutConfigSchema, ValidationError, createATProtoSDK };
3536
- export type { ATProtoSDKConfig, AuthorizeOptions, BlobOperations, BlobRef, CacheInterface, Collaborator, CollaboratorOperations, CollaboratorPermissions, CreateHypercertParams, CreateHypercertResult, CreateResult, DID, HypercertClaim, HypercertCollection, HypercertCollectionClaimItem, HypercertContribution, HypercertEvaluation, HypercertEvents, HypercertEvidence, HypercertImage, HypercertLocation, HypercertMeasurement, HypercertOperations, HypercertRights, HypercertWithMetadata, ListParams, LoggerInterface, Organization, OrganizationInfo, OrganizationOperations, PaginatedList, ProfileOperations, ProgressStep, RecordOperations, RepositoryAccessGrant, RepositoryOptions, RepositoryRole, Session, SessionStore, StateStore, StrongRef, UpdateResult, ValidationResult };
3669
+ /**
3670
+ * OAuth Scopes and Granular Permissions
3671
+ *
3672
+ * This module provides type-safe, Zod-validated OAuth scope and permission management
3673
+ * for the ATProto SDK. It supports both legacy transitional scopes and the new
3674
+ * granular permissions model.
3675
+ *
3676
+ * @see https://atproto.com/specs/oauth
3677
+ * @see https://atproto.com/specs/permission
3678
+ *
3679
+ * @module auth/permissions
3680
+ */
3681
+
3682
+ /**
3683
+ * Base OAuth scope - required for all sessions
3684
+ *
3685
+ * @constant
3686
+ */
3687
+ declare const ATPROTO_SCOPE: "atproto";
3688
+ /**
3689
+ * Transitional OAuth scopes for legacy compatibility.
3690
+ *
3691
+ * These scopes provide broad access and are maintained for backwards compatibility.
3692
+ * New applications should use granular permissions instead.
3693
+ *
3694
+ * @deprecated Use granular permissions (account:*, repo:*, etc.) for better control
3695
+ * @constant
3696
+ */
3697
+ declare const TRANSITION_SCOPES: {
3698
+ /** Broad PDS permissions including record creation, blob uploads, and preferences */
3699
+ readonly GENERIC: "transition:generic";
3700
+ /** Direct messages access (requires transition:generic) */
3701
+ readonly CHAT: "transition:chat.bsky";
3702
+ /** Email address and confirmation status */
3703
+ readonly EMAIL: "transition:email";
3704
+ };
3705
+ /**
3706
+ * Zod schema for transitional scopes.
3707
+ *
3708
+ * Validates that a scope string is one of the known transitional scopes.
3709
+ *
3710
+ * @example
3711
+ * ```typescript
3712
+ * TransitionScopeSchema.parse('transition:email'); // Valid
3713
+ * TransitionScopeSchema.parse('invalid'); // Throws ZodError
3714
+ * ```
3715
+ */
3716
+ declare const TransitionScopeSchema: z.ZodEnum<["transition:generic", "transition:chat.bsky", "transition:email"]>;
3717
+ /**
3718
+ * Type for transitional scopes inferred from schema.
3719
+ */
3720
+ type TransitionScope = z.infer<typeof TransitionScopeSchema>;
3721
+ /**
3722
+ * Zod schema for account permission attributes.
3723
+ *
3724
+ * Account attributes specify what aspect of the account is being accessed.
3725
+ */
3726
+ declare const AccountAttrSchema: z.ZodEnum<["email", "repo"]>;
3727
+ /**
3728
+ * Type for account attributes inferred from schema.
3729
+ */
3730
+ type AccountAttr = z.infer<typeof AccountAttrSchema>;
3731
+ /**
3732
+ * Zod schema for account actions.
3733
+ *
3734
+ * Account actions specify the level of access (read-only or management).
3735
+ */
3736
+ declare const AccountActionSchema: z.ZodEnum<["read", "manage"]>;
3737
+ /**
3738
+ * Type for account actions inferred from schema.
3739
+ */
3740
+ type AccountAction = z.infer<typeof AccountActionSchema>;
3741
+ /**
3742
+ * Zod schema for repository actions.
3743
+ *
3744
+ * Repository actions specify what operations can be performed on records.
3745
+ */
3746
+ declare const RepoActionSchema: z.ZodEnum<["create", "update", "delete"]>;
3747
+ /**
3748
+ * Type for repository actions inferred from schema.
3749
+ */
3750
+ type RepoAction = z.infer<typeof RepoActionSchema>;
3751
+ /**
3752
+ * Zod schema for identity permission attributes.
3753
+ *
3754
+ * Identity attributes specify what identity information can be managed.
3755
+ */
3756
+ declare const IdentityAttrSchema: z.ZodEnum<["handle", "*"]>;
3757
+ /**
3758
+ * Type for identity attributes inferred from schema.
3759
+ */
3760
+ type IdentityAttr = z.infer<typeof IdentityAttrSchema>;
3761
+ /**
3762
+ * Zod schema for MIME type patterns.
3763
+ *
3764
+ * Validates MIME type strings like "image/*" or "video/mp4".
3765
+ *
3766
+ * @example
3767
+ * ```typescript
3768
+ * MimeTypeSchema.parse('image/*'); // Valid
3769
+ * MimeTypeSchema.parse('video/mp4'); // Valid
3770
+ * MimeTypeSchema.parse('invalid'); // Throws ZodError
3771
+ * ```
3772
+ */
3773
+ declare const MimeTypeSchema: z.ZodString;
3774
+ /**
3775
+ * Zod schema for NSID (Namespaced Identifier).
3776
+ *
3777
+ * NSIDs are reverse-DNS style identifiers used throughout ATProto
3778
+ * (e.g., "app.bsky.feed.post" or "com.example.myrecord").
3779
+ *
3780
+ * @see https://atproto.com/specs/nsid
3781
+ *
3782
+ * @example
3783
+ * ```typescript
3784
+ * NsidSchema.parse('app.bsky.feed.post'); // Valid
3785
+ * NsidSchema.parse('com.example.myrecord'); // Valid
3786
+ * NsidSchema.parse('InvalidNSID'); // Throws ZodError
3787
+ * ```
3788
+ */
3789
+ declare const NsidSchema: z.ZodString;
3790
+ /**
3791
+ * Zod schema for account permission.
3792
+ *
3793
+ * Account permissions control access to account-level information like email
3794
+ * and repository management.
3795
+ *
3796
+ * @example Without action (read-only)
3797
+ * ```typescript
3798
+ * const input = { type: 'account', attr: 'email' };
3799
+ * AccountPermissionSchema.parse(input); // Returns: "account:email"
3800
+ * ```
3801
+ *
3802
+ * @example With action
3803
+ * ```typescript
3804
+ * const input = { type: 'account', attr: 'email', action: 'manage' };
3805
+ * AccountPermissionSchema.parse(input); // Returns: "account:email?action=manage"
3806
+ * ```
3807
+ */
3808
+ declare const AccountPermissionSchema: z.ZodEffects<z.ZodObject<{
3809
+ type: z.ZodLiteral<"account">;
3810
+ attr: z.ZodEnum<["email", "repo"]>;
3811
+ action: z.ZodOptional<z.ZodEnum<["read", "manage"]>>;
3812
+ }, "strip", z.ZodTypeAny, {
3813
+ type: "account";
3814
+ attr: "email" | "repo";
3815
+ action?: "read" | "manage" | undefined;
3816
+ }, {
3817
+ type: "account";
3818
+ attr: "email" | "repo";
3819
+ action?: "read" | "manage" | undefined;
3820
+ }>, string, {
3821
+ type: "account";
3822
+ attr: "email" | "repo";
3823
+ action?: "read" | "manage" | undefined;
3824
+ }>;
3825
+ /**
3826
+ * Input type for account permission (before transform).
3827
+ */
3828
+ type AccountPermissionInput = z.input<typeof AccountPermissionSchema>;
3829
+ /**
3830
+ * Zod schema for repository permission.
3831
+ *
3832
+ * Repository permissions control write access to records by collection type.
3833
+ * The collection must be a valid NSID or wildcard (*).
3834
+ *
3835
+ * @example Without actions (all actions allowed)
3836
+ * ```typescript
3837
+ * const input = { type: 'repo', collection: 'app.bsky.feed.post' };
3838
+ * RepoPermissionSchema.parse(input); // Returns: "repo:app.bsky.feed.post"
3839
+ * ```
3840
+ *
3841
+ * @example With specific actions
3842
+ * ```typescript
3843
+ * const input = {
3844
+ * type: 'repo',
3845
+ * collection: 'app.bsky.feed.post',
3846
+ * actions: ['create', 'update']
3847
+ * };
3848
+ * RepoPermissionSchema.parse(input); // Returns: "repo:app.bsky.feed.post?action=create&action=update"
3849
+ * ```
3850
+ *
3851
+ * @example With wildcard collection
3852
+ * ```typescript
3853
+ * const input = { type: 'repo', collection: '*', actions: ['delete'] };
3854
+ * RepoPermissionSchema.parse(input); // Returns: "repo:*?action=delete"
3855
+ * ```
3856
+ */
3857
+ declare const RepoPermissionSchema: z.ZodEffects<z.ZodObject<{
3858
+ type: z.ZodLiteral<"repo">;
3859
+ collection: z.ZodUnion<[z.ZodString, z.ZodLiteral<"*">]>;
3860
+ actions: z.ZodOptional<z.ZodArray<z.ZodEnum<["create", "update", "delete"]>, "many">>;
3861
+ }, "strip", z.ZodTypeAny, {
3862
+ type: "repo";
3863
+ collection: string;
3864
+ actions?: ("create" | "update" | "delete")[] | undefined;
3865
+ }, {
3866
+ type: "repo";
3867
+ collection: string;
3868
+ actions?: ("create" | "update" | "delete")[] | undefined;
3869
+ }>, string, {
3870
+ type: "repo";
3871
+ collection: string;
3872
+ actions?: ("create" | "update" | "delete")[] | undefined;
3873
+ }>;
3874
+ /**
3875
+ * Input type for repository permission (before transform).
3876
+ */
3877
+ type RepoPermissionInput = z.input<typeof RepoPermissionSchema>;
3878
+ /**
3879
+ * Zod schema for blob permission.
3880
+ *
3881
+ * Blob permissions control media file uploads constrained by MIME type patterns.
3882
+ *
3883
+ * @example Single MIME type
3884
+ * ```typescript
3885
+ * const input = { type: 'blob', mimeTypes: ['image/*'] };
3886
+ * BlobPermissionSchema.parse(input); // Returns: "blob:image/*"
3887
+ * ```
3888
+ *
3889
+ * @example Multiple MIME types
3890
+ * ```typescript
3891
+ * const input = { type: 'blob', mimeTypes: ['image/*', 'video/*'] };
3892
+ * BlobPermissionSchema.parse(input); // Returns: "blob?accept=image/*&accept=video/*"
3893
+ * ```
3894
+ */
3895
+ declare const BlobPermissionSchema: z.ZodEffects<z.ZodObject<{
3896
+ type: z.ZodLiteral<"blob">;
3897
+ mimeTypes: z.ZodArray<z.ZodString, "many">;
3898
+ }, "strip", z.ZodTypeAny, {
3899
+ type: "blob";
3900
+ mimeTypes: string[];
3901
+ }, {
3902
+ type: "blob";
3903
+ mimeTypes: string[];
3904
+ }>, string, {
3905
+ type: "blob";
3906
+ mimeTypes: string[];
3907
+ }>;
3908
+ /**
3909
+ * Input type for blob permission (before transform).
3910
+ */
3911
+ type BlobPermissionInput = z.input<typeof BlobPermissionSchema>;
3912
+ /**
3913
+ * Zod schema for RPC permission.
3914
+ *
3915
+ * RPC permissions control authenticated API calls to remote services.
3916
+ * At least one of lexicon or aud must be restricted (both cannot be wildcards).
3917
+ *
3918
+ * @example Specific lexicon with wildcard audience
3919
+ * ```typescript
3920
+ * const input = {
3921
+ * type: 'rpc',
3922
+ * lexicon: 'com.atproto.repo.createRecord',
3923
+ * aud: '*'
3924
+ * };
3925
+ * RpcPermissionSchema.parse(input);
3926
+ * // Returns: "rpc:com.atproto.repo.createRecord?aud=*"
3927
+ * ```
3928
+ *
3929
+ * @example With specific audience
3930
+ * ```typescript
3931
+ * const input = {
3932
+ * type: 'rpc',
3933
+ * lexicon: 'com.atproto.repo.createRecord',
3934
+ * aud: 'did:web:api.example.com',
3935
+ * inheritAud: true
3936
+ * };
3937
+ * RpcPermissionSchema.parse(input);
3938
+ * // Returns: "rpc:com.atproto.repo.createRecord?aud=did%3Aweb%3Aapi.example.com&inheritAud=true"
3939
+ * ```
3940
+ */
3941
+ declare const RpcPermissionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
3942
+ type: z.ZodLiteral<"rpc">;
3943
+ lexicon: z.ZodUnion<[z.ZodString, z.ZodLiteral<"*">]>;
3944
+ aud: z.ZodString;
3945
+ inheritAud: z.ZodOptional<z.ZodBoolean>;
3946
+ }, "strip", z.ZodTypeAny, {
3947
+ type: "rpc";
3948
+ lexicon: string;
3949
+ aud: string;
3950
+ inheritAud?: boolean | undefined;
3951
+ }, {
3952
+ type: "rpc";
3953
+ lexicon: string;
3954
+ aud: string;
3955
+ inheritAud?: boolean | undefined;
3956
+ }>, {
3957
+ type: "rpc";
3958
+ lexicon: string;
3959
+ aud: string;
3960
+ inheritAud?: boolean | undefined;
3961
+ }, {
3962
+ type: "rpc";
3963
+ lexicon: string;
3964
+ aud: string;
3965
+ inheritAud?: boolean | undefined;
3966
+ }>, string, {
3967
+ type: "rpc";
3968
+ lexicon: string;
3969
+ aud: string;
3970
+ inheritAud?: boolean | undefined;
3971
+ }>;
3972
+ /**
3973
+ * Input type for RPC permission (before transform).
3974
+ */
3975
+ type RpcPermissionInput = z.input<typeof RpcPermissionSchema>;
3976
+ /**
3977
+ * Zod schema for identity permission.
3978
+ *
3979
+ * Identity permissions control access to DID documents and handles.
3980
+ *
3981
+ * @example Handle management
3982
+ * ```typescript
3983
+ * const input = { type: 'identity', attr: 'handle' };
3984
+ * IdentityPermissionSchema.parse(input); // Returns: "identity:handle"
3985
+ * ```
3986
+ *
3987
+ * @example All identity attributes
3988
+ * ```typescript
3989
+ * const input = { type: 'identity', attr: '*' };
3990
+ * IdentityPermissionSchema.parse(input); // Returns: "identity:*"
3991
+ * ```
3992
+ */
3993
+ declare const IdentityPermissionSchema: z.ZodEffects<z.ZodObject<{
3994
+ type: z.ZodLiteral<"identity">;
3995
+ attr: z.ZodEnum<["handle", "*"]>;
3996
+ }, "strip", z.ZodTypeAny, {
3997
+ type: "identity";
3998
+ attr: "handle" | "*";
3999
+ }, {
4000
+ type: "identity";
4001
+ attr: "handle" | "*";
4002
+ }>, string, {
4003
+ type: "identity";
4004
+ attr: "handle" | "*";
4005
+ }>;
4006
+ /**
4007
+ * Input type for identity permission (before transform).
4008
+ */
4009
+ type IdentityPermissionInput = z.input<typeof IdentityPermissionSchema>;
4010
+ /**
4011
+ * Zod schema for permission set inclusion.
4012
+ *
4013
+ * Include permissions reference permission sets bundled under a single NSID.
4014
+ *
4015
+ * @example Without audience
4016
+ * ```typescript
4017
+ * const input = { type: 'include', nsid: 'com.example.authBasicFeatures' };
4018
+ * IncludePermissionSchema.parse(input);
4019
+ * // Returns: "include:com.example.authBasicFeatures"
4020
+ * ```
4021
+ *
4022
+ * @example With audience
4023
+ * ```typescript
4024
+ * const input = {
4025
+ * type: 'include',
4026
+ * nsid: 'com.example.authBasicFeatures',
4027
+ * aud: 'did:web:api.example.com'
4028
+ * };
4029
+ * IncludePermissionSchema.parse(input);
4030
+ * // Returns: "include:com.example.authBasicFeatures?aud=did%3Aweb%3Aapi.example.com"
4031
+ * ```
4032
+ */
4033
+ declare const IncludePermissionSchema: z.ZodEffects<z.ZodObject<{
4034
+ type: z.ZodLiteral<"include">;
4035
+ nsid: z.ZodString;
4036
+ aud: z.ZodOptional<z.ZodString>;
4037
+ }, "strip", z.ZodTypeAny, {
4038
+ type: "include";
4039
+ nsid: string;
4040
+ aud?: string | undefined;
4041
+ }, {
4042
+ type: "include";
4043
+ nsid: string;
4044
+ aud?: string | undefined;
4045
+ }>, string, {
4046
+ type: "include";
4047
+ nsid: string;
4048
+ aud?: string | undefined;
4049
+ }>;
4050
+ /**
4051
+ * Input type for include permission (before transform).
4052
+ */
4053
+ type IncludePermissionInput = z.input<typeof IncludePermissionSchema>;
4054
+ /**
4055
+ * Union schema for all permission types.
4056
+ *
4057
+ * This schema accepts any of the supported permission types and validates
4058
+ * them according to their specific rules.
4059
+ */
4060
+ declare const PermissionSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
4061
+ type: z.ZodLiteral<"account">;
4062
+ attr: z.ZodEnum<["email", "repo"]>;
4063
+ action: z.ZodOptional<z.ZodEnum<["read", "manage"]>>;
4064
+ }, "strip", z.ZodTypeAny, {
4065
+ type: "account";
4066
+ attr: "email" | "repo";
4067
+ action?: "read" | "manage" | undefined;
4068
+ }, {
4069
+ type: "account";
4070
+ attr: "email" | "repo";
4071
+ action?: "read" | "manage" | undefined;
4072
+ }>, string, {
4073
+ type: "account";
4074
+ attr: "email" | "repo";
4075
+ action?: "read" | "manage" | undefined;
4076
+ }>, z.ZodEffects<z.ZodObject<{
4077
+ type: z.ZodLiteral<"repo">;
4078
+ collection: z.ZodUnion<[z.ZodString, z.ZodLiteral<"*">]>;
4079
+ actions: z.ZodOptional<z.ZodArray<z.ZodEnum<["create", "update", "delete"]>, "many">>;
4080
+ }, "strip", z.ZodTypeAny, {
4081
+ type: "repo";
4082
+ collection: string;
4083
+ actions?: ("create" | "update" | "delete")[] | undefined;
4084
+ }, {
4085
+ type: "repo";
4086
+ collection: string;
4087
+ actions?: ("create" | "update" | "delete")[] | undefined;
4088
+ }>, string, {
4089
+ type: "repo";
4090
+ collection: string;
4091
+ actions?: ("create" | "update" | "delete")[] | undefined;
4092
+ }>, z.ZodEffects<z.ZodObject<{
4093
+ type: z.ZodLiteral<"blob">;
4094
+ mimeTypes: z.ZodArray<z.ZodString, "many">;
4095
+ }, "strip", z.ZodTypeAny, {
4096
+ type: "blob";
4097
+ mimeTypes: string[];
4098
+ }, {
4099
+ type: "blob";
4100
+ mimeTypes: string[];
4101
+ }>, string, {
4102
+ type: "blob";
4103
+ mimeTypes: string[];
4104
+ }>, z.ZodEffects<z.ZodEffects<z.ZodObject<{
4105
+ type: z.ZodLiteral<"rpc">;
4106
+ lexicon: z.ZodUnion<[z.ZodString, z.ZodLiteral<"*">]>;
4107
+ aud: z.ZodString;
4108
+ inheritAud: z.ZodOptional<z.ZodBoolean>;
4109
+ }, "strip", z.ZodTypeAny, {
4110
+ type: "rpc";
4111
+ lexicon: string;
4112
+ aud: string;
4113
+ inheritAud?: boolean | undefined;
4114
+ }, {
4115
+ type: "rpc";
4116
+ lexicon: string;
4117
+ aud: string;
4118
+ inheritAud?: boolean | undefined;
4119
+ }>, {
4120
+ type: "rpc";
4121
+ lexicon: string;
4122
+ aud: string;
4123
+ inheritAud?: boolean | undefined;
4124
+ }, {
4125
+ type: "rpc";
4126
+ lexicon: string;
4127
+ aud: string;
4128
+ inheritAud?: boolean | undefined;
4129
+ }>, string, {
4130
+ type: "rpc";
4131
+ lexicon: string;
4132
+ aud: string;
4133
+ inheritAud?: boolean | undefined;
4134
+ }>, z.ZodEffects<z.ZodObject<{
4135
+ type: z.ZodLiteral<"identity">;
4136
+ attr: z.ZodEnum<["handle", "*"]>;
4137
+ }, "strip", z.ZodTypeAny, {
4138
+ type: "identity";
4139
+ attr: "handle" | "*";
4140
+ }, {
4141
+ type: "identity";
4142
+ attr: "handle" | "*";
4143
+ }>, string, {
4144
+ type: "identity";
4145
+ attr: "handle" | "*";
4146
+ }>, z.ZodEffects<z.ZodObject<{
4147
+ type: z.ZodLiteral<"include">;
4148
+ nsid: z.ZodString;
4149
+ aud: z.ZodOptional<z.ZodString>;
4150
+ }, "strip", z.ZodTypeAny, {
4151
+ type: "include";
4152
+ nsid: string;
4153
+ aud?: string | undefined;
4154
+ }, {
4155
+ type: "include";
4156
+ nsid: string;
4157
+ aud?: string | undefined;
4158
+ }>, string, {
4159
+ type: "include";
4160
+ nsid: string;
4161
+ aud?: string | undefined;
4162
+ }>]>;
4163
+ /**
4164
+ * Input type for any permission (before transform).
4165
+ */
4166
+ type PermissionInput = z.input<typeof PermissionSchema>;
4167
+ /**
4168
+ * Output type for any permission (after transform).
4169
+ */
4170
+ type Permission = z.output<typeof PermissionSchema>;
4171
+ /**
4172
+ * Fluent builder for constructing OAuth permission arrays.
4173
+ *
4174
+ * This class provides a convenient, type-safe way to build arrays of permissions
4175
+ * using method chaining.
4176
+ *
4177
+ * @example Basic usage
4178
+ * ```typescript
4179
+ * const builder = new PermissionBuilder()
4180
+ * .accountEmail('read')
4181
+ * .repoWrite('app.bsky.feed.post')
4182
+ * .blob(['image/*', 'video/*']);
4183
+ *
4184
+ * const permissions = builder.build();
4185
+ * // Returns: ['account:email?action=read', 'repo:app.bsky.feed.post?action=create&action=update', 'blob:image/*,video/*']
4186
+ * ```
4187
+ *
4188
+ * @example With transitional scopes
4189
+ * ```typescript
4190
+ * const builder = new PermissionBuilder()
4191
+ * .transition('email')
4192
+ * .transition('generic');
4193
+ *
4194
+ * const scopes = builder.build();
4195
+ * // Returns: ['transition:email', 'transition:generic']
4196
+ * ```
4197
+ */
4198
+ declare class PermissionBuilder {
4199
+ private permissions;
4200
+ /**
4201
+ * Add a transitional scope.
4202
+ *
4203
+ * @param scope - The transitional scope name ('email', 'generic', or 'chat.bsky')
4204
+ * @returns This builder for chaining
4205
+ *
4206
+ * @example
4207
+ * ```typescript
4208
+ * builder.transition('email').transition('generic');
4209
+ * ```
4210
+ */
4211
+ transition(scope: "email" | "generic" | "chat.bsky"): this;
4212
+ /**
4213
+ * Add an account permission.
4214
+ *
4215
+ * @param attr - The account attribute ('email' or 'repo')
4216
+ * @param action - Optional action ('read' or 'manage')
4217
+ * @returns This builder for chaining
4218
+ *
4219
+ * @example
4220
+ * ```typescript
4221
+ * builder.accountEmail('read').accountRepo('manage');
4222
+ * ```
4223
+ */
4224
+ account(attr: z.infer<typeof AccountAttrSchema>, action?: z.infer<typeof AccountActionSchema>): this;
4225
+ /**
4226
+ * Convenience method for account:email permission.
4227
+ *
4228
+ * @param action - Optional action ('read' or 'manage')
4229
+ * @returns This builder for chaining
4230
+ *
4231
+ * @example
4232
+ * ```typescript
4233
+ * builder.accountEmail('read');
4234
+ * ```
4235
+ */
4236
+ accountEmail(action?: z.infer<typeof AccountActionSchema>): this;
4237
+ /**
4238
+ * Convenience method for account:repo permission.
4239
+ *
4240
+ * @param action - Optional action ('read' or 'manage')
4241
+ * @returns This builder for chaining
4242
+ *
4243
+ * @example
4244
+ * ```typescript
4245
+ * builder.accountRepo('manage');
4246
+ * ```
4247
+ */
4248
+ accountRepo(action?: z.infer<typeof AccountActionSchema>): this;
4249
+ /**
4250
+ * Add a repository permission.
4251
+ *
4252
+ * @param collection - The NSID of the collection or '*' for all
4253
+ * @param actions - Optional array of actions ('create', 'update', 'delete')
4254
+ * @returns This builder for chaining
4255
+ *
4256
+ * @example
4257
+ * ```typescript
4258
+ * builder.repo('app.bsky.feed.post', ['create', 'update']);
4259
+ * ```
4260
+ */
4261
+ repo(collection: string, actions?: z.infer<typeof RepoActionSchema>[]): this;
4262
+ /**
4263
+ * Convenience method for repository write permissions (create + update).
4264
+ *
4265
+ * @param collection - The NSID of the collection or '*' for all
4266
+ * @returns This builder for chaining
4267
+ *
4268
+ * @example
4269
+ * ```typescript
4270
+ * builder.repoWrite('app.bsky.feed.post');
4271
+ * ```
4272
+ */
4273
+ repoWrite(collection: string): this;
4274
+ /**
4275
+ * Convenience method for repository read permission (no actions).
4276
+ *
4277
+ * @param collection - The NSID of the collection or '*' for all
4278
+ * @returns This builder for chaining
4279
+ *
4280
+ * @example
4281
+ * ```typescript
4282
+ * builder.repoRead('app.bsky.feed.post');
4283
+ * ```
4284
+ */
4285
+ repoRead(collection: string): this;
4286
+ /**
4287
+ * Convenience method for full repository permissions (create + update + delete).
4288
+ *
4289
+ * @param collection - The NSID of the collection or '*' for all
4290
+ * @returns This builder for chaining
4291
+ *
4292
+ * @example
4293
+ * ```typescript
4294
+ * builder.repoFull('app.bsky.feed.post');
4295
+ * ```
4296
+ */
4297
+ repoFull(collection: string): this;
4298
+ /**
4299
+ * Add a blob permission.
4300
+ *
4301
+ * @param mimeTypes - Array of MIME types or a single MIME type
4302
+ * @returns This builder for chaining
4303
+ *
4304
+ * @example
4305
+ * ```typescript
4306
+ * builder.blob(['image/*', 'video/*']);
4307
+ * builder.blob('image/*');
4308
+ * ```
4309
+ */
4310
+ blob(mimeTypes: string | string[]): this;
4311
+ /**
4312
+ * Add an RPC permission.
4313
+ *
4314
+ * @param lexicon - The NSID of the lexicon or '*' for all
4315
+ * @param aud - The audience (DID or URL)
4316
+ * @param inheritAud - Whether to inherit audience
4317
+ * @returns This builder for chaining
4318
+ *
4319
+ * @example
4320
+ * ```typescript
4321
+ * builder.rpc('com.atproto.repo.createRecord', 'did:web:api.example.com');
4322
+ * ```
4323
+ */
4324
+ rpc(lexicon: string, aud: string, inheritAud?: boolean): this;
4325
+ /**
4326
+ * Add an identity permission.
4327
+ *
4328
+ * @param attr - The identity attribute ('handle' or '*')
4329
+ * @returns This builder for chaining
4330
+ *
4331
+ * @example
4332
+ * ```typescript
4333
+ * builder.identity('handle');
4334
+ * ```
4335
+ */
4336
+ identity(attr: z.infer<typeof IdentityAttrSchema>): this;
4337
+ /**
4338
+ * Add an include permission.
4339
+ *
4340
+ * @param nsid - The NSID of the scope set to include
4341
+ * @param aud - Optional audience restriction
4342
+ * @returns This builder for chaining
4343
+ *
4344
+ * @example
4345
+ * ```typescript
4346
+ * builder.include('com.example.authBasicFeatures');
4347
+ * ```
4348
+ */
4349
+ include(nsid: string, aud?: string): this;
4350
+ /**
4351
+ * Add a custom permission string directly (bypasses validation).
4352
+ *
4353
+ * Use this for testing or special cases where you need to add
4354
+ * a permission that doesn't fit the standard types.
4355
+ *
4356
+ * @param permission - The permission string
4357
+ * @returns This builder for chaining
4358
+ *
4359
+ * @example
4360
+ * ```typescript
4361
+ * builder.custom('atproto');
4362
+ * ```
4363
+ */
4364
+ custom(permission: string): this;
4365
+ /**
4366
+ * Add the base atproto scope.
4367
+ *
4368
+ * @returns This builder for chaining
4369
+ *
4370
+ * @example
4371
+ * ```typescript
4372
+ * builder.atproto();
4373
+ * ```
4374
+ */
4375
+ atproto(): this;
4376
+ /**
4377
+ * Build and return the array of permission strings.
4378
+ *
4379
+ * @returns Array of permission strings
4380
+ *
4381
+ * @example
4382
+ * ```typescript
4383
+ * const permissions = builder.build();
4384
+ * ```
4385
+ */
4386
+ build(): string[];
4387
+ /**
4388
+ * Clear all permissions from the builder.
4389
+ *
4390
+ * @returns This builder for chaining
4391
+ *
4392
+ * @example
4393
+ * ```typescript
4394
+ * builder.clear().accountEmail('read');
4395
+ * ```
4396
+ */
4397
+ clear(): this;
4398
+ /**
4399
+ * Get the current number of permissions.
4400
+ *
4401
+ * @returns The number of permissions
4402
+ *
4403
+ * @example
4404
+ * ```typescript
4405
+ * const count = builder.count();
4406
+ * ```
4407
+ */
4408
+ count(): number;
4409
+ }
4410
+ /**
4411
+ * Build a scope string from an array of permissions.
4412
+ *
4413
+ * This is a convenience function that joins permission strings with spaces,
4414
+ * which is the standard format for OAuth scope parameters.
4415
+ *
4416
+ * @param permissions - Array of permission strings
4417
+ * @returns Space-separated scope string
4418
+ *
4419
+ * @example
4420
+ * ```typescript
4421
+ * const permissions = ['account:email?action=read', 'repo:app.bsky.feed.post'];
4422
+ * const scope = buildScope(permissions);
4423
+ * // Returns: "account:email?action=read repo:app.bsky.feed.post"
4424
+ * ```
4425
+ */
4426
+ declare function buildScope(permissions: string[]): string;
4427
+ /**
4428
+ * Pre-built scope presets for common use cases.
4429
+ *
4430
+ * These presets provide ready-to-use permission sets for typical application scenarios.
4431
+ */
4432
+ declare const ScopePresets: {
4433
+ /**
4434
+ * Email access scope - allows reading user's email address.
4435
+ *
4436
+ * Includes:
4437
+ * - account:email?action=read
4438
+ *
4439
+ * @example
4440
+ * ```typescript
4441
+ * const scope = ScopePresets.EMAIL_READ;
4442
+ * // Use in OAuth flow to request email access
4443
+ * ```
4444
+ */
4445
+ readonly EMAIL_READ: string;
4446
+ /**
4447
+ * Profile read scope - allows reading user's profile.
4448
+ *
4449
+ * Includes:
4450
+ * - repo:app.bsky.actor.profile (read-only)
4451
+ *
4452
+ * @example
4453
+ * ```typescript
4454
+ * const scope = ScopePresets.PROFILE_READ;
4455
+ * ```
4456
+ */
4457
+ readonly PROFILE_READ: string;
4458
+ /**
4459
+ * Profile write scope - allows updating user's profile.
4460
+ *
4461
+ * Includes:
4462
+ * - repo:app.bsky.actor.profile (create + update)
4463
+ *
4464
+ * @example
4465
+ * ```typescript
4466
+ * const scope = ScopePresets.PROFILE_WRITE;
4467
+ * ```
4468
+ */
4469
+ readonly PROFILE_WRITE: string;
4470
+ /**
4471
+ * Post creation scope - allows creating and updating posts.
4472
+ *
4473
+ * Includes:
4474
+ * - repo:app.bsky.feed.post (create + update)
4475
+ *
4476
+ * @example
4477
+ * ```typescript
4478
+ * const scope = ScopePresets.POST_WRITE;
4479
+ * ```
4480
+ */
4481
+ readonly POST_WRITE: string;
4482
+ /**
4483
+ * Social interactions scope - allows liking, reposting, and following.
4484
+ *
4485
+ * Includes:
4486
+ * - repo:app.bsky.feed.like (create + update)
4487
+ * - repo:app.bsky.feed.repost (create + update)
4488
+ * - repo:app.bsky.graph.follow (create + update)
4489
+ *
4490
+ * @example
4491
+ * ```typescript
4492
+ * const scope = ScopePresets.SOCIAL_WRITE;
4493
+ * ```
4494
+ */
4495
+ readonly SOCIAL_WRITE: string;
4496
+ /**
4497
+ * Media upload scope - allows uploading images and videos.
4498
+ *
4499
+ * Includes:
4500
+ * - blob permissions for image/* and video/*
4501
+ *
4502
+ * @example
4503
+ * ```typescript
4504
+ * const scope = ScopePresets.MEDIA_UPLOAD;
4505
+ * ```
4506
+ */
4507
+ readonly MEDIA_UPLOAD: string;
4508
+ /**
4509
+ * Image upload only scope - allows uploading images.
4510
+ *
4511
+ * Includes:
4512
+ * - blob:image/*
4513
+ *
4514
+ * @example
4515
+ * ```typescript
4516
+ * const scope = ScopePresets.IMAGE_UPLOAD;
4517
+ * ```
4518
+ */
4519
+ readonly IMAGE_UPLOAD: string;
4520
+ /**
4521
+ * Posting app scope - full posting capabilities including media.
4522
+ *
4523
+ * Includes:
4524
+ * - repo:app.bsky.feed.post (create + update)
4525
+ * - repo:app.bsky.feed.like (create + update)
4526
+ * - repo:app.bsky.feed.repost (create + update)
4527
+ * - blob permissions for image/* and video/*
4528
+ *
4529
+ * @example
4530
+ * ```typescript
4531
+ * const scope = ScopePresets.POSTING_APP;
4532
+ * ```
4533
+ */
4534
+ readonly POSTING_APP: string;
4535
+ /**
4536
+ * Read-only app scope - allows reading all repository data.
4537
+ *
4538
+ * Includes:
4539
+ * - repo:* (read-only, no actions)
4540
+ *
4541
+ * @example
4542
+ * ```typescript
4543
+ * const scope = ScopePresets.READ_ONLY;
4544
+ * ```
4545
+ */
4546
+ readonly READ_ONLY: string;
4547
+ /**
4548
+ * Full access scope - allows all repository operations.
4549
+ *
4550
+ * Includes:
4551
+ * - repo:* (create + update + delete)
4552
+ *
4553
+ * @example
4554
+ * ```typescript
4555
+ * const scope = ScopePresets.FULL_ACCESS;
4556
+ * ```
4557
+ */
4558
+ readonly FULL_ACCESS: string;
4559
+ /**
4560
+ * Email + Profile scope - common combination for user identification.
4561
+ *
4562
+ * Includes:
4563
+ * - account:email?action=read
4564
+ * - repo:app.bsky.actor.profile (read-only)
4565
+ *
4566
+ * @example
4567
+ * ```typescript
4568
+ * const scope = ScopePresets.EMAIL_AND_PROFILE;
4569
+ * ```
4570
+ */
4571
+ readonly EMAIL_AND_PROFILE: string;
4572
+ /**
4573
+ * Transitional email scope (legacy).
4574
+ *
4575
+ * Uses the transitional scope format for backward compatibility.
4576
+ *
4577
+ * @example
4578
+ * ```typescript
4579
+ * const scope = ScopePresets.TRANSITION_EMAIL;
4580
+ * ```
4581
+ */
4582
+ readonly TRANSITION_EMAIL: string;
4583
+ /**
4584
+ * Transitional generic scope (legacy).
4585
+ *
4586
+ * Uses the transitional scope format for backward compatibility.
4587
+ *
4588
+ * @example
4589
+ * ```typescript
4590
+ * const scope = ScopePresets.TRANSITION_GENERIC;
4591
+ * ```
4592
+ */
4593
+ readonly TRANSITION_GENERIC: string;
4594
+ };
4595
+ /**
4596
+ * Parse a scope string into an array of individual permissions.
4597
+ *
4598
+ * This splits a space-separated scope string into individual permission strings.
4599
+ *
4600
+ * @param scope - Space-separated scope string
4601
+ * @returns Array of permission strings
4602
+ *
4603
+ * @example
4604
+ * ```typescript
4605
+ * const scope = "account:email?action=read repo:app.bsky.feed.post";
4606
+ * const permissions = parseScope(scope);
4607
+ * // Returns: ['account:email?action=read', 'repo:app.bsky.feed.post']
4608
+ * ```
4609
+ */
4610
+ declare function parseScope(scope: string): string[];
4611
+ /**
4612
+ * Check if a scope string contains a specific permission.
4613
+ *
4614
+ * This function performs exact string matching. For more advanced
4615
+ * permission checking (e.g., wildcard matching), you'll need to
4616
+ * implement custom logic.
4617
+ *
4618
+ * @param scope - Space-separated scope string
4619
+ * @param permission - The permission to check for
4620
+ * @returns True if the scope contains the permission
4621
+ *
4622
+ * @example
4623
+ * ```typescript
4624
+ * const scope = "account:email?action=read repo:app.bsky.feed.post";
4625
+ * hasPermission(scope, "account:email?action=read"); // true
4626
+ * hasPermission(scope, "account:repo"); // false
4627
+ * ```
4628
+ */
4629
+ declare function hasPermission(scope: string, permission: string): boolean;
4630
+ /**
4631
+ * Check if a scope string contains all of the specified permissions.
4632
+ *
4633
+ * @param scope - Space-separated scope string
4634
+ * @param requiredPermissions - Array of permissions to check for
4635
+ * @returns True if the scope contains all required permissions
4636
+ *
4637
+ * @example
4638
+ * ```typescript
4639
+ * const scope = "account:email?action=read repo:app.bsky.feed.post blob:image/*";
4640
+ * hasAllPermissions(scope, ["account:email?action=read", "blob:image/*"]); // true
4641
+ * hasAllPermissions(scope, ["account:email?action=read", "account:repo"]); // false
4642
+ * ```
4643
+ */
4644
+ declare function hasAllPermissions(scope: string, requiredPermissions: string[]): boolean;
4645
+ /**
4646
+ * Check if a scope string contains any of the specified permissions.
4647
+ *
4648
+ * @param scope - Space-separated scope string
4649
+ * @param checkPermissions - Array of permissions to check for
4650
+ * @returns True if the scope contains at least one of the permissions
4651
+ *
4652
+ * @example
4653
+ * ```typescript
4654
+ * const scope = "account:email?action=read repo:app.bsky.feed.post";
4655
+ * hasAnyPermission(scope, ["account:email?action=read", "account:repo"]); // true
4656
+ * hasAnyPermission(scope, ["account:repo", "identity:handle"]); // false
4657
+ * ```
4658
+ */
4659
+ declare function hasAnyPermission(scope: string, checkPermissions: string[]): boolean;
4660
+ /**
4661
+ * Merge multiple scope strings into a single scope string with deduplicated permissions.
4662
+ *
4663
+ * @param scopes - Array of scope strings to merge
4664
+ * @returns Merged scope string with unique permissions
4665
+ *
4666
+ * @example
4667
+ * ```typescript
4668
+ * const scope1 = "account:email?action=read repo:app.bsky.feed.post";
4669
+ * const scope2 = "repo:app.bsky.feed.post blob:image/*";
4670
+ * const merged = mergeScopes([scope1, scope2]);
4671
+ * // Returns: "account:email?action=read repo:app.bsky.feed.post blob:image/*"
4672
+ * ```
4673
+ */
4674
+ declare function mergeScopes(scopes: string[]): string;
4675
+ /**
4676
+ * Remove specific permissions from a scope string.
4677
+ *
4678
+ * @param scope - Space-separated scope string
4679
+ * @param permissionsToRemove - Array of permissions to remove
4680
+ * @returns New scope string without the specified permissions
4681
+ *
4682
+ * @example
4683
+ * ```typescript
4684
+ * const scope = "account:email?action=read repo:app.bsky.feed.post blob:image/*";
4685
+ * const filtered = removePermissions(scope, ["blob:image/*"]);
4686
+ * // Returns: "account:email?action=read repo:app.bsky.feed.post"
4687
+ * ```
4688
+ */
4689
+ declare function removePermissions(scope: string, permissionsToRemove: string[]): string;
4690
+ /**
4691
+ * Validate that all permissions in a scope string are well-formed.
4692
+ *
4693
+ * This checks that each permission matches expected patterns for transitional
4694
+ * or granular permissions. It does NOT validate against the full Zod schemas.
4695
+ *
4696
+ * @param scope - Space-separated scope string
4697
+ * @returns Object with isValid flag and array of invalid permissions
4698
+ *
4699
+ * @example
4700
+ * ```typescript
4701
+ * const scope = "account:email?action=read invalid:permission";
4702
+ * const result = validateScope(scope);
4703
+ * // Returns: { isValid: false, invalidPermissions: ['invalid:permission'] }
4704
+ * ```
4705
+ */
4706
+ declare function validateScope(scope: string): {
4707
+ isValid: boolean;
4708
+ invalidPermissions: string[];
4709
+ };
4710
+
4711
+ export { ATPROTO_SCOPE, ATProtoSDK, ATProtoSDKConfigSchema, ATProtoSDKError, AccountActionSchema, AccountAttrSchema, AccountPermissionSchema, AuthenticationError, BlobPermissionSchema, CollaboratorPermissionsSchema, CollaboratorSchema, ConfigurableAgent, IdentityAttrSchema, IdentityPermissionSchema, InMemorySessionStore, InMemoryStateStore, IncludePermissionSchema, LexiconRegistry, MimeTypeSchema, NetworkError, NsidSchema, OAuthConfigSchema, OrganizationSchema, PermissionBuilder, PermissionSchema, RepoActionSchema, RepoPermissionSchema, Repository, RpcPermissionSchema, SDSRequiredError, ScopePresets, ServerConfigSchema, SessionExpiredError, TRANSITION_SCOPES, TimeoutConfigSchema, TransitionScopeSchema, ValidationError, buildScope, createATProtoSDK, hasAllPermissions, hasAnyPermission, hasPermission, mergeScopes, parseScope, removePermissions, validateScope };
4712
+ export type { ATProtoSDKConfig, AccountAction, AccountAttr, AccountPermissionInput, AuthorizeOptions, BlobOperations, BlobPermissionInput, BlobRef, CacheInterface, Collaborator, CollaboratorOperations, CollaboratorPermissions, CreateHypercertParams, CreateHypercertResult, CreateResult, DID, HypercertClaim, HypercertCollection, HypercertCollectionClaimItem, HypercertContribution, HypercertEvaluation, HypercertEvents, HypercertEvidence, HypercertImage, HypercertLocation, HypercertMeasurement, HypercertOperations, HypercertRights, HypercertWithMetadata, IdentityAttr, IdentityPermissionInput, IncludePermissionInput, ListParams, LoggerInterface, Organization, OrganizationInfo, OrganizationOperations, PaginatedList, Permission, PermissionInput, ProfileOperations, ProgressStep, RecordOperations, RepoAction, RepoPermissionInput, RepositoryAccessGrant, RepositoryOptions, RepositoryRole, RpcPermissionInput, Session, SessionStore, StateStore, StrongRef, TransitionScope, UpdateResult, ValidationResult };