techne-sdk 0.9.0 → 0.11.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.
@@ -3326,6 +3326,86 @@ export const schemaDict = {
3326
3326
  },
3327
3327
  },
3328
3328
  },
3329
+ PubTechneDraftIdentityAttachLinkGrant: {
3330
+ lexicon: 1,
3331
+ id: 'pub.techne.draft.identity.attachLinkGrant',
3332
+ defs: {
3333
+ main: {
3334
+ type: 'procedure',
3335
+ description: "Attach a grant to a link token the caller made on their own identity PDS (an app holding its own session calls createLinkToken or resetLinkToken there, then this through its PDS). The platform asks the identity PDS (checkLinkToken) whether `token` is live and the caller's; it then keeps `grant` for that link as createLinkToken with `grant` does. `grant.actAs` must be a collective (`ActAsPerson` otherwise): a person's records are written by their own app, never by the platform for someone else's tap, so a link to a person's thing carries no grant and its owner's app acts on the redemptions it lists. The same rules hold: the grant writes as the account the link's target names, the caller must be able to write as `grant.actAs` now and when the link is redeemed, and the record must be one permissioned.putRecord would take with the caller's DID in the slot. Such a grant is released only in the redeemer's own request: their app redeems the link at its identity PDS, then calls claimLinkGrant; it is never released in the background. Releasing a grant that writes as a circle relies on the platform holding the circle's key, a named exception that goes when collectives can grant the platform like any account. One grant per link: attaching the same grant again answers as the first time; a different one is `AlreadyGranted`. A redemption reported before the grant was attached releases nothing, so attach before sharing the link. Only an account hosted on the platform's identity PDS can attach a grant. One call spends one of the caller's writes.",
3336
+ input: {
3337
+ encoding: 'application/json',
3338
+ schema: {
3339
+ type: 'object',
3340
+ required: ['token', 'grant'],
3341
+ properties: {
3342
+ token: {
3343
+ type: 'string',
3344
+ minLength: 1,
3345
+ maxLength: 512,
3346
+ description: "The link's token, as the identity PDS answered it to the caller.",
3347
+ },
3348
+ grant: {
3349
+ type: 'ref',
3350
+ ref: 'lex:pub.techne.draft.identity.defs#linkGrant',
3351
+ },
3352
+ },
3353
+ },
3354
+ },
3355
+ output: {
3356
+ encoding: 'application/json',
3357
+ schema: {
3358
+ type: 'object',
3359
+ required: ['id'],
3360
+ properties: {
3361
+ id: {
3362
+ type: 'string',
3363
+ description: "The link's id on the identity PDS.",
3364
+ },
3365
+ },
3366
+ },
3367
+ },
3368
+ errors: [
3369
+ {
3370
+ name: 'InvalidRequest',
3371
+ description: "HTTP 400: a field out of bounds, the grant does not write as the account the link's target names, or a body that is not JSON; 413: the body, or `grant.write`, over its size cap; 415: not application/json; 422: not the input's shape.",
3372
+ },
3373
+ {
3374
+ name: 'LinkNotUsable',
3375
+ description: "HTTP 400: the token names no live link of the caller's.",
3376
+ },
3377
+ {
3378
+ name: 'ActAsPerson',
3379
+ description: "HTTP 400: `grant.actAs` is not a collective the platform knows (a person, or an unknown account); only a collective's grant can be attached.",
3380
+ },
3381
+ {
3382
+ name: 'AlreadyGranted',
3383
+ description: 'HTTP 409: the link already carries another grant.',
3384
+ },
3385
+ {
3386
+ name: 'Forbidden',
3387
+ description: 'HTTP 403: `grant.actAs` is not an account the caller may write as.',
3388
+ },
3389
+ {
3390
+ name: 'ProgramRefused',
3391
+ description: "HTTP 403: an agent's or program's token may not attach a grant that writes an approval record.",
3392
+ },
3393
+ {
3394
+ name: 'NotSupported',
3395
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
3396
+ },
3397
+ {
3398
+ name: 'RateLimitExceeded',
3399
+ description: "HTTP 429: too many writes from this DID, or the identity PDS is limiting the platform's checks; try again later.",
3400
+ },
3401
+ {
3402
+ name: 'UpstreamFailure',
3403
+ description: 'HTTP 502: the identity PDS could not be reached or answered with a failure; try again.',
3404
+ },
3405
+ ],
3406
+ },
3407
+ },
3408
+ },
3329
3409
  PubTechneDraftIdentityAttest: {
3330
3410
  lexicon: 1,
3331
3411
  id: 'pub.techne.draft.identity.attest',
@@ -3603,6 +3683,84 @@ export const schemaDict = {
3603
3683
  },
3604
3684
  },
3605
3685
  },
3686
+ PubTechneDraftIdentityClaimLinkGrant: {
3687
+ lexicon: 1,
3688
+ id: 'pub.techne.draft.identity.claimLinkGrant',
3689
+ defs: {
3690
+ main: {
3691
+ type: 'procedure',
3692
+ description: "Release, now, the grant of a link the caller redeemed on their own identity PDS (an app holding its own session calls redeemLinkToken there, then this through its PDS, in the same user action). The platform needs the redemption the identity PDS reported for the caller; it writes the grant's record as the grant's `actAs` in this request, under the grant's rules (the link's owner may still write as `actAs`, no block between owner and redeemer). The platform never releases such a grant in the background. Claiming a link again releases its grant again only for a reusable link still live under `token` (someone removed from a circle who opens its link again is a member again); otherwise it answers `written: false`. One call spends one of the caller's writes.",
3693
+ input: {
3694
+ encoding: 'application/json',
3695
+ schema: {
3696
+ type: 'object',
3697
+ required: ['id', 'token'],
3698
+ properties: {
3699
+ id: {
3700
+ type: 'string',
3701
+ minLength: 1,
3702
+ maxLength: 512,
3703
+ description: "The link's id, as redeemLinkToken answered it.",
3704
+ },
3705
+ token: {
3706
+ type: 'string',
3707
+ minLength: 1,
3708
+ maxLength: 512,
3709
+ description: "The link's token, as redeemed.",
3710
+ },
3711
+ },
3712
+ },
3713
+ },
3714
+ output: {
3715
+ encoding: 'application/json',
3716
+ schema: {
3717
+ type: 'object',
3718
+ required: ['id', 'written'],
3719
+ properties: {
3720
+ id: {
3721
+ type: 'string',
3722
+ description: "The link's id.",
3723
+ },
3724
+ written: {
3725
+ type: 'boolean',
3726
+ description: "Whether the grant's record was written by this call.",
3727
+ },
3728
+ reason: {
3729
+ type: 'string',
3730
+ description: 'When nothing was written: why (the record is already there, the link carries no grant, it was revoked, the grant was released before, ...). Free text, for logs.',
3731
+ },
3732
+ },
3733
+ },
3734
+ },
3735
+ errors: [
3736
+ {
3737
+ name: 'InvalidRequest',
3738
+ description: "HTTP 400: a field out of bounds, or a body that is not JSON; 413: the body over its size cap; 415: not application/json; 422: not the input's shape.",
3739
+ },
3740
+ {
3741
+ name: 'NotRedeemed',
3742
+ description: 'HTTP 409: no redemption of this link by the caller has been reported by the identity PDS (yet); redeem it there first.',
3743
+ },
3744
+ {
3745
+ name: 'TryAgain',
3746
+ description: 'HTTP 503: the release could not finish now; claim it again.',
3747
+ },
3748
+ {
3749
+ name: 'NotSupported',
3750
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
3751
+ },
3752
+ {
3753
+ name: 'RateLimitExceeded',
3754
+ description: "HTTP 429: too many writes from this DID, or the identity PDS is limiting the platform's checks; try again later.",
3755
+ },
3756
+ {
3757
+ name: 'UpstreamFailure',
3758
+ description: 'HTTP 502: the identity PDS could not be reached or answered with a failure; try again.',
3759
+ },
3760
+ ],
3761
+ },
3762
+ },
3763
+ },
3606
3764
  PubTechneDraftIdentityCreateCollective: {
3607
3765
  lexicon: 1,
3608
3766
  id: 'pub.techne.draft.identity.createCollective',
@@ -3724,7 +3882,7 @@ export const schemaDict = {
3724
3882
  },
3725
3883
  {
3726
3884
  name: 'NotSupported',
3727
- description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
3885
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there; or the caller holds its own session (it came through its PDS with a service-auth token): call this method on its identity PDS itself and attach a grant with attachLinkGrant.",
3728
3886
  },
3729
3887
  {
3730
3888
  name: 'RateLimitExceeded',
@@ -4480,7 +4638,7 @@ export const schemaDict = {
4480
4638
  },
4481
4639
  {
4482
4640
  name: 'NotSupported',
4483
- description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
4641
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there; or the caller holds its own session (it came through its PDS with a service-auth token): call this method on its identity PDS itself.",
4484
4642
  },
4485
4643
  {
4486
4644
  name: 'RateLimitExceeded',
@@ -4545,7 +4703,7 @@ export const schemaDict = {
4545
4703
  },
4546
4704
  {
4547
4705
  name: 'NotSupported',
4548
- description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
4706
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there; or the caller holds its own session (it came through its PDS with a service-auth token): call this method on its identity PDS itself.",
4549
4707
  },
4550
4708
  {
4551
4709
  name: 'RateLimitExceeded',
@@ -5397,7 +5555,7 @@ export const schemaDict = {
5397
5555
  defs: {
5398
5556
  main: {
5399
5557
  type: 'procedure',
5400
- description: "Redeem a link token as the caller. The identity PDS records it and reports it to the platform, which writes the caller's linkRedemption record and the link's grant, usually before this answers. Redeeming again a link the caller already redeemed answers `repeat` and changes nothing. One call spends one of the caller's writes. An older link (one the served app made before link tokens) writes no linkRedemption record.",
5558
+ description: "Redeem a link token as the caller. The identity PDS records it and reports it to the platform, which writes the caller's linkRedemption record and the link's grant, usually before this answers. Redeeming again a link the caller already redeemed answers `repeat` and changes nothing. One call spends one of the caller's writes. An older link (one the served app made before link tokens) writes no linkRedemption record. A caller that holds its own session redeems at its identity PDS and then calls claimLinkGrant; here it opens only the app's links from before link tokens. A link whose grant was attached with attachLinkGrant has it released in this request.",
5401
5559
  input: {
5402
5560
  encoding: 'application/json',
5403
5561
  schema: {
@@ -5458,7 +5616,7 @@ export const schemaDict = {
5458
5616
  },
5459
5617
  {
5460
5618
  name: 'LinkNotUsable',
5461
- description: 'HTTP 400: the link is unknown, revoked, expired or already used by another account ("this link no longer works").',
5619
+ description: 'HTTP 400: the link is unknown, revoked, expired or already used by another account ("this link no longer works"); or, for a caller that holds its own session, any token but one of the app\'s links from before link tokens.',
5462
5620
  },
5463
5621
  {
5464
5622
  name: 'OwnLink',
@@ -5588,7 +5746,7 @@ export const schemaDict = {
5588
5746
  },
5589
5747
  {
5590
5748
  name: 'NotSupported',
5591
- description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
5749
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there; or the caller holds its own session (it came through its PDS with a service-auth token): call this method on its identity PDS itself and attach a grant with attachLinkGrant.",
5592
5750
  },
5593
5751
  {
5594
5752
  name: 'RateLimitExceeded',
@@ -5733,7 +5891,7 @@ export const schemaDict = {
5733
5891
  },
5734
5892
  {
5735
5893
  name: 'NotSupported',
5736
- description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
5894
+ description: "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there; or the caller holds its own session (it came through its PDS with a service-auth token): call this method on its identity PDS itself.",
5737
5895
  },
5738
5896
  {
5739
5897
  name: 'RateLimitExceeded',
@@ -12079,10 +12237,12 @@ export const ids = {
12079
12237
  PubTechneDraftGeo: 'pub.techne.draft.geo',
12080
12238
  PubTechneDraftHeldAt: 'pub.techne.draft.heldAt',
12081
12239
  PubTechneDraftIdentityAccountsForPhones: 'pub.techne.draft.identity.accountsForPhones',
12240
+ PubTechneDraftIdentityAttachLinkGrant: 'pub.techne.draft.identity.attachLinkGrant',
12082
12241
  PubTechneDraftIdentityAttest: 'pub.techne.draft.identity.attest',
12083
12242
  PubTechneDraftIdentityBeginAddMethod: 'pub.techne.draft.identity.beginAddMethod',
12084
12243
  PubTechneDraftIdentityCancelPendingChange: 'pub.techne.draft.identity.cancelPendingChange',
12085
12244
  PubTechneDraftIdentityCheckLinkToken: 'pub.techne.draft.identity.checkLinkToken',
12245
+ PubTechneDraftIdentityClaimLinkGrant: 'pub.techne.draft.identity.claimLinkGrant',
12086
12246
  PubTechneDraftIdentityCreateCollective: 'pub.techne.draft.identity.createCollective',
12087
12247
  PubTechneDraftIdentityCreateLinkToken: 'pub.techne.draft.identity.createLinkToken',
12088
12248
  PubTechneDraftIdentityDefs: 'pub.techne.draft.identity.defs',
@@ -90,10 +90,12 @@ export declare const NSID: {
90
90
  readonly HYPERCERTS_AUTHORITY: "org.hypercerts";
91
91
  readonly IDENTITY_ACCOUNTS_FOR_PHONES: "pub.techne.draft.identity.accountsForPhones";
92
92
  readonly IDENTITY_ACCOUNTS_FOR_PHONES_ACCOUNT: "pub.techne.draft.identity.accountsForPhones#account";
93
+ readonly IDENTITY_ATTACH_LINK_GRANT: "pub.techne.draft.identity.attachLinkGrant";
93
94
  readonly IDENTITY_ATTEST: "pub.techne.draft.identity.attest";
94
95
  readonly IDENTITY_BEGIN_ADD_METHOD: "pub.techne.draft.identity.beginAddMethod";
95
96
  readonly IDENTITY_CANCEL_PENDING_CHANGE: "pub.techne.draft.identity.cancelPendingChange";
96
97
  readonly IDENTITY_CHECK_LINK_TOKEN: "pub.techne.draft.identity.checkLinkToken";
98
+ readonly IDENTITY_CLAIM_LINK_GRANT: "pub.techne.draft.identity.claimLinkGrant";
97
99
  readonly IDENTITY_CREATE_COLLECTIVE: "pub.techne.draft.identity.createCollective";
98
100
  readonly IDENTITY_CREATE_LINK_TOKEN: "pub.techne.draft.identity.createLinkToken";
99
101
  readonly IDENTITY_DEFS: "pub.techne.draft.identity.defs";
@@ -94,10 +94,12 @@ export const NSID = {
94
94
  HYPERCERTS_AUTHORITY: 'org.hypercerts',
95
95
  IDENTITY_ACCOUNTS_FOR_PHONES: 'pub.techne.draft.identity.accountsForPhones',
96
96
  IDENTITY_ACCOUNTS_FOR_PHONES_ACCOUNT: 'pub.techne.draft.identity.accountsForPhones#account',
97
+ IDENTITY_ATTACH_LINK_GRANT: 'pub.techne.draft.identity.attachLinkGrant',
97
98
  IDENTITY_ATTEST: 'pub.techne.draft.identity.attest',
98
99
  IDENTITY_BEGIN_ADD_METHOD: 'pub.techne.draft.identity.beginAddMethod',
99
100
  IDENTITY_CANCEL_PENDING_CHANGE: 'pub.techne.draft.identity.cancelPendingChange',
100
101
  IDENTITY_CHECK_LINK_TOKEN: 'pub.techne.draft.identity.checkLinkToken',
102
+ IDENTITY_CLAIM_LINK_GRANT: 'pub.techne.draft.identity.claimLinkGrant',
101
103
  IDENTITY_CREATE_COLLECTIVE: 'pub.techne.draft.identity.createCollective',
102
104
  IDENTITY_CREATE_LINK_TOKEN: 'pub.techne.draft.identity.createLinkToken',
103
105
  IDENTITY_DEFS: 'pub.techne.draft.identity.defs',
@@ -90,10 +90,12 @@
90
90
  "HYPERCERTS_AUTHORITY": "org.hypercerts",
91
91
  "IDENTITY_ACCOUNTS_FOR_PHONES": "pub.techne.draft.identity.accountsForPhones",
92
92
  "IDENTITY_ACCOUNTS_FOR_PHONES_ACCOUNT": "pub.techne.draft.identity.accountsForPhones#account",
93
+ "IDENTITY_ATTACH_LINK_GRANT": "pub.techne.draft.identity.attachLinkGrant",
93
94
  "IDENTITY_ATTEST": "pub.techne.draft.identity.attest",
94
95
  "IDENTITY_BEGIN_ADD_METHOD": "pub.techne.draft.identity.beginAddMethod",
95
96
  "IDENTITY_CANCEL_PENDING_CHANGE": "pub.techne.draft.identity.cancelPendingChange",
96
97
  "IDENTITY_CHECK_LINK_TOKEN": "pub.techne.draft.identity.checkLinkToken",
98
+ "IDENTITY_CLAIM_LINK_GRANT": "pub.techne.draft.identity.claimLinkGrant",
97
99
  "IDENTITY_CREATE_COLLECTIVE": "pub.techne.draft.identity.createCollective",
98
100
  "IDENTITY_CREATE_LINK_TOKEN": "pub.techne.draft.identity.createLinkToken",
99
101
  "IDENTITY_DEFS": "pub.techne.draft.identity.defs",
@@ -0,0 +1,54 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
+ import type * as PubTechneDraftIdentityDefs from './defs.js';
6
+ export type QueryParams = {};
7
+ export interface InputSchema {
8
+ /** The link's token, as the identity PDS answered it to the caller. */
9
+ token: string;
10
+ grant: PubTechneDraftIdentityDefs.LinkGrant;
11
+ }
12
+ export interface OutputSchema {
13
+ /** The link's id on the identity PDS. */
14
+ id: string;
15
+ }
16
+ export interface CallOptions {
17
+ signal?: AbortSignal;
18
+ headers?: HeadersMap;
19
+ qp?: QueryParams;
20
+ encoding?: 'application/json';
21
+ }
22
+ export interface Response {
23
+ success: boolean;
24
+ headers: HeadersMap;
25
+ data: OutputSchema;
26
+ }
27
+ export declare class InvalidRequestError extends XRPCError {
28
+ constructor(src: XRPCError);
29
+ }
30
+ export declare class LinkNotUsableError extends XRPCError {
31
+ constructor(src: XRPCError);
32
+ }
33
+ export declare class ActAsPersonError extends XRPCError {
34
+ constructor(src: XRPCError);
35
+ }
36
+ export declare class AlreadyGrantedError extends XRPCError {
37
+ constructor(src: XRPCError);
38
+ }
39
+ export declare class ForbiddenError extends XRPCError {
40
+ constructor(src: XRPCError);
41
+ }
42
+ export declare class ProgramRefusedError extends XRPCError {
43
+ constructor(src: XRPCError);
44
+ }
45
+ export declare class NotSupportedError extends XRPCError {
46
+ constructor(src: XRPCError);
47
+ }
48
+ export declare class RateLimitExceededError extends XRPCError {
49
+ constructor(src: XRPCError);
50
+ }
51
+ export declare class UpstreamFailureError extends XRPCError {
52
+ constructor(src: XRPCError);
53
+ }
54
+ export declare function toKnownErr(e: any): any;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { XRPCError } from '@atproto/xrpc';
5
+ import { validate as _validate } from '../../../../../lexicons.js';
6
+ import { is$typed as _is$typed, } from '../../../../../util.js';
7
+ const is$typed = _is$typed, validate = _validate;
8
+ const id = 'pub.techne.draft.identity.attachLinkGrant';
9
+ export class InvalidRequestError extends XRPCError {
10
+ constructor(src) {
11
+ super(src.status, src.error, src.message, src.headers, { cause: src });
12
+ }
13
+ }
14
+ export class LinkNotUsableError extends XRPCError {
15
+ constructor(src) {
16
+ super(src.status, src.error, src.message, src.headers, { cause: src });
17
+ }
18
+ }
19
+ export class ActAsPersonError extends XRPCError {
20
+ constructor(src) {
21
+ super(src.status, src.error, src.message, src.headers, { cause: src });
22
+ }
23
+ }
24
+ export class AlreadyGrantedError extends XRPCError {
25
+ constructor(src) {
26
+ super(src.status, src.error, src.message, src.headers, { cause: src });
27
+ }
28
+ }
29
+ export class ForbiddenError extends XRPCError {
30
+ constructor(src) {
31
+ super(src.status, src.error, src.message, src.headers, { cause: src });
32
+ }
33
+ }
34
+ export class ProgramRefusedError extends XRPCError {
35
+ constructor(src) {
36
+ super(src.status, src.error, src.message, src.headers, { cause: src });
37
+ }
38
+ }
39
+ export class NotSupportedError extends XRPCError {
40
+ constructor(src) {
41
+ super(src.status, src.error, src.message, src.headers, { cause: src });
42
+ }
43
+ }
44
+ export class RateLimitExceededError extends XRPCError {
45
+ constructor(src) {
46
+ super(src.status, src.error, src.message, src.headers, { cause: src });
47
+ }
48
+ }
49
+ export class UpstreamFailureError extends XRPCError {
50
+ constructor(src) {
51
+ super(src.status, src.error, src.message, src.headers, { cause: src });
52
+ }
53
+ }
54
+ export function toKnownErr(e) {
55
+ if (e instanceof XRPCError) {
56
+ if (e.error === 'InvalidRequest')
57
+ return new InvalidRequestError(e);
58
+ if (e.error === 'LinkNotUsable')
59
+ return new LinkNotUsableError(e);
60
+ if (e.error === 'ActAsPerson')
61
+ return new ActAsPersonError(e);
62
+ if (e.error === 'AlreadyGranted')
63
+ return new AlreadyGrantedError(e);
64
+ if (e.error === 'Forbidden')
65
+ return new ForbiddenError(e);
66
+ if (e.error === 'ProgramRefused')
67
+ return new ProgramRefusedError(e);
68
+ if (e.error === 'NotSupported')
69
+ return new NotSupportedError(e);
70
+ if (e.error === 'RateLimitExceeded')
71
+ return new RateLimitExceededError(e);
72
+ if (e.error === 'UpstreamFailure')
73
+ return new UpstreamFailureError(e);
74
+ }
75
+ return e;
76
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
+ export type QueryParams = {};
6
+ export interface InputSchema {
7
+ /** The link's id, as redeemLinkToken answered it. */
8
+ id: string;
9
+ /** The link's token, as redeemed. */
10
+ token: string;
11
+ }
12
+ export interface OutputSchema {
13
+ /** The link's id. */
14
+ id: string;
15
+ /** Whether the grant's record was written by this call. */
16
+ written: boolean;
17
+ /** When nothing was written: why (the record is already there, the link carries no grant, it was revoked, the grant was released before, ...). Free text, for logs. */
18
+ reason?: string;
19
+ }
20
+ export interface CallOptions {
21
+ signal?: AbortSignal;
22
+ headers?: HeadersMap;
23
+ qp?: QueryParams;
24
+ encoding?: 'application/json';
25
+ }
26
+ export interface Response {
27
+ success: boolean;
28
+ headers: HeadersMap;
29
+ data: OutputSchema;
30
+ }
31
+ export declare class InvalidRequestError extends XRPCError {
32
+ constructor(src: XRPCError);
33
+ }
34
+ export declare class NotRedeemedError extends XRPCError {
35
+ constructor(src: XRPCError);
36
+ }
37
+ export declare class TryAgainError extends XRPCError {
38
+ constructor(src: XRPCError);
39
+ }
40
+ export declare class NotSupportedError extends XRPCError {
41
+ constructor(src: XRPCError);
42
+ }
43
+ export declare class RateLimitExceededError extends XRPCError {
44
+ constructor(src: XRPCError);
45
+ }
46
+ export declare class UpstreamFailureError extends XRPCError {
47
+ constructor(src: XRPCError);
48
+ }
49
+ export declare function toKnownErr(e: any): any;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { XRPCError } from '@atproto/xrpc';
5
+ import { validate as _validate } from '../../../../../lexicons.js';
6
+ import { is$typed as _is$typed, } from '../../../../../util.js';
7
+ const is$typed = _is$typed, validate = _validate;
8
+ const id = 'pub.techne.draft.identity.claimLinkGrant';
9
+ export class InvalidRequestError extends XRPCError {
10
+ constructor(src) {
11
+ super(src.status, src.error, src.message, src.headers, { cause: src });
12
+ }
13
+ }
14
+ export class NotRedeemedError extends XRPCError {
15
+ constructor(src) {
16
+ super(src.status, src.error, src.message, src.headers, { cause: src });
17
+ }
18
+ }
19
+ export class TryAgainError extends XRPCError {
20
+ constructor(src) {
21
+ super(src.status, src.error, src.message, src.headers, { cause: src });
22
+ }
23
+ }
24
+ export class NotSupportedError extends XRPCError {
25
+ constructor(src) {
26
+ super(src.status, src.error, src.message, src.headers, { cause: src });
27
+ }
28
+ }
29
+ export class RateLimitExceededError extends XRPCError {
30
+ constructor(src) {
31
+ super(src.status, src.error, src.message, src.headers, { cause: src });
32
+ }
33
+ }
34
+ export class UpstreamFailureError extends XRPCError {
35
+ constructor(src) {
36
+ super(src.status, src.error, src.message, src.headers, { cause: src });
37
+ }
38
+ }
39
+ export function toKnownErr(e) {
40
+ if (e instanceof XRPCError) {
41
+ if (e.error === 'InvalidRequest')
42
+ return new InvalidRequestError(e);
43
+ if (e.error === 'NotRedeemed')
44
+ return new NotRedeemedError(e);
45
+ if (e.error === 'TryAgain')
46
+ return new TryAgainError(e);
47
+ if (e.error === 'NotSupported')
48
+ return new NotSupportedError(e);
49
+ if (e.error === 'RateLimitExceeded')
50
+ return new RateLimitExceededError(e);
51
+ if (e.error === 'UpstreamFailure')
52
+ return new UpstreamFailureError(e);
53
+ }
54
+ return e;
55
+ }
@@ -31,6 +31,9 @@
31
31
  * set it came from; otherwise the store's (newer) set is taken.
32
32
  * - an answer the device cannot use after the token rotated (no access token, another `sub`) ends the
33
33
  * session: the old token is spent, so keeping it would end the grant later anyway.
34
+ * - **A session that ends** (the PDS refused a refresh: the grant was revoked, say on the account page) clears
35
+ * the store and signs the device credential out too (best effort), so the platform drops the phone's push
36
+ * token then rather than when the device session expires.
34
37
  * - **Sign-out** waits for a refresh in flight, revokes the grant (`revokeOwnSession`) and the device
35
38
  * credential (`signOutDevice`), each given up after {@link SIGN_OUT_TIMEOUT_MS}, and clears the store,
36
39
  * whatever the network says. When the store holds another key's set it touches neither that set nor the
@@ -96,12 +99,7 @@ export interface OwnSessionOptions {
96
99
  now?: () => number;
97
100
  sleep?: (ms: number) => Promise<void>;
98
101
  }
99
- /** How long the platform keeps a refresh's answer for the same token and key. */
100
- export declare const PLATFORM_ANSWER_WINDOW_MS = 60000;
101
- /** How long after the first send a refresh that got no answer may be sent again. */
102
- export declare const LOST_ANSWER_WINDOW_MS = 50000;
103
- /** Every send is given up this long before {@link PLATFORM_ANSWER_WINDOW_MS} ends (clock skew, transit). */
104
- export declare const SEND_MARGIN_MS = 5000;
102
+ export { LOST_ANSWER_WINDOW_MS, PLATFORM_ANSWER_WINDOW_MS, SEND_MARGIN_MS } from './relay.js';
105
103
  /** How long sign-out waits for each of its calls (revoke, signOutDevice). */
106
104
  export declare const SIGN_OUT_TIMEOUT_MS = 10000;
107
105
  /** An early refresh holds the call only when the access token has less than this to live. */
@@ -111,6 +109,8 @@ export declare function nonceKey(url: string): string;
111
109
  /** The proof headers for a device-credential request: `Authorization: Bearer <rsds_>` and a `DPoP` proof by
112
110
  * `key` for `method` `url` with `ath` over the credential (no server nonce is asked for). */
113
111
  export declare function deviceProofHeaders(key: DpopKey, deviceSession: string, method: string, url: string): Record<string, string>;
112
+ /** The same token set (access and refresh token). */
113
+ export declare function sameSet(a: Pick<OwnSessionData, 'accessToken' | 'refreshToken'>, b: Pick<OwnSessionData, 'accessToken' | 'refreshToken'>): boolean;
114
114
  /** The device's own session (module doc). Make one with {@link OwnSession.restore} or {@link OwnSession.signedIn}.
115
115
  * The tokens and the key are in `#private` fields, so logging the session prints neither. */
116
116
  export declare class OwnSession {