techne-sdk 0.13.1 → 0.15.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/CHANGELOG.md +93 -3
- package/README.md +66 -17
- package/dist/auth/hints.d.ts +14 -0
- package/dist/auth/hints.js +18 -0
- package/dist/auth/index.d.ts +19 -1
- package/dist/auth/index.js +48 -1
- package/dist/catalog/catalog.gen.d.ts +35 -29
- package/dist/catalog/catalog.gen.js +427 -64
- package/dist/generated/index.d.ts +56 -0
- package/dist/generated/index.js +72 -0
- package/dist/generated/lexicons.d.ts +164 -26
- package/dist/generated/lexicons.js +84 -12
- package/dist/generated/nsid.d.ts +8 -0
- package/dist/generated/nsid.js +8 -0
- package/dist/generated/nsid.json +8 -0
- package/dist/generated/records.d.ts +94 -90
- package/dist/generated/types/pub/techne/draft/beacon.d.ts +2 -0
- package/dist/generated/types/pub/techne/draft/derivation.d.ts +1 -1
- package/dist/generated/types/pub/techne/draft/evaluation.d.ts +3 -1
- package/dist/generated/types/pub/techne/draft/follow.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/follow.js +12 -0
- package/dist/generated/types/pub/techne/draft/notificationPref.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/notificationPref.js +12 -0
- package/dist/generated/types/pub/techne/draft/org.d.ts +2 -2
- package/dist/generated/types/pub/techne/draft/statement.d.ts +1 -1
- package/dist/query/index.d.ts +3 -2
- package/dist/react/sign-in.d.ts +34 -0
- package/dist/react/sign-in.js +52 -0
- package/dist/session/phone.d.ts +7 -6
- package/dist/session/phone.js +7 -6
- package/dist/session/relay.d.ts +1 -1
- package/dist/session/relay.js +1 -1
- package/dist/sign-in/index.d.ts +33 -0
- package/dist/sign-in/index.js +479 -0
- package/dist/sign-in/styles.d.ts +22 -0
- package/dist/sign-in/styles.js +108 -0
- package/dist/wasm/techne-wasm.gen.js +1 -1
- package/dist/wasm/techne-wasm2js.gen.js +7330 -7332
- package/package.json +14 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GENERATED CODE - DO NOT MODIFY
|
|
3
3
|
*/
|
|
4
|
-
import { type ValidationResult } from '@atproto/lexicon';
|
|
4
|
+
import { type ValidationResult, BlobRef } from '@atproto/lexicon';
|
|
5
5
|
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
6
6
|
export interface Main {
|
|
7
7
|
$type: 'pub.techne.draft.evaluation';
|
|
@@ -10,6 +10,8 @@ export interface Main {
|
|
|
10
10
|
direction: 'positive' | 'negative' | (string & {});
|
|
11
11
|
/** Optional free-form note. */
|
|
12
12
|
note?: string;
|
|
13
|
+
/** Optional photo of the subject, set by the evaluator: a blob in the evaluator's own repo. Apps show it only when the subject has no picture of its own. */
|
|
14
|
+
image?: BlobRef;
|
|
13
15
|
createdAt: string;
|
|
14
16
|
[k: string]: unknown;
|
|
15
17
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
export interface Main {
|
|
6
|
+
$type: 'pub.techne.draft.follow';
|
|
7
|
+
/** The person followed. */
|
|
8
|
+
subject: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.follow", "main">;
|
|
13
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
14
|
+
export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { validate as _validate } from '../../../../lexicons.js';
|
|
2
|
+
import { is$typed as _is$typed, } from '../../../../util.js';
|
|
3
|
+
const is$typed = _is$typed, validate = _validate;
|
|
4
|
+
const id = 'pub.techne.draft.follow';
|
|
5
|
+
const hashMain = 'main';
|
|
6
|
+
export function isMain(v) {
|
|
7
|
+
return is$typed(v, id, hashMain);
|
|
8
|
+
}
|
|
9
|
+
export function validateMain(v) {
|
|
10
|
+
return validate(v, id, hashMain, true);
|
|
11
|
+
}
|
|
12
|
+
export { isMain as isRecord, validateMain as validateRecord, };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
export interface Main {
|
|
6
|
+
$type: 'pub.techne.draft.notificationPref';
|
|
7
|
+
/** The kind of notice. An unknown kind is kept and ignored. */
|
|
8
|
+
kind: 'curator.new' | 'curator.picks' | (string & {});
|
|
9
|
+
/** Send this kind of notice (push and the other interrupting channels). The in-app inbox is not switched. */
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.notificationPref", "main">;
|
|
15
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
16
|
+
export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { validate as _validate } from '../../../../lexicons.js';
|
|
2
|
+
import { is$typed as _is$typed, } from '../../../../util.js';
|
|
3
|
+
const is$typed = _is$typed, validate = _validate;
|
|
4
|
+
const id = 'pub.techne.draft.notificationPref';
|
|
5
|
+
const hashMain = 'main';
|
|
6
|
+
export function isMain(v) {
|
|
7
|
+
return is$typed(v, id, hashMain);
|
|
8
|
+
}
|
|
9
|
+
export function validateMain(v) {
|
|
10
|
+
return validate(v, id, hashMain, true);
|
|
11
|
+
}
|
|
12
|
+
export { isMain as isRecord, validateMain as validateRecord, };
|
|
@@ -26,7 +26,7 @@ export interface Main {
|
|
|
26
26
|
url?: string;
|
|
27
27
|
/** Public phone number, E.164. */
|
|
28
28
|
phone?: string;
|
|
29
|
-
/** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location.
|
|
29
|
+
/** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. With a `pub.techne.draft.statement` about the org carrying `locations` (a site the org's author did not state), this replaces `pub.techne.draft.orgAtPlace`. */
|
|
30
30
|
locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationHthree.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<PubTechneDraftLocationEntry.Main> | {
|
|
31
31
|
$type: string;
|
|
32
32
|
})[];
|
|
@@ -55,7 +55,7 @@ export interface Fields {
|
|
|
55
55
|
url?: string;
|
|
56
56
|
/** Public phone number, E.164. */
|
|
57
57
|
phone?: string;
|
|
58
|
-
/** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location.
|
|
58
|
+
/** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. With a `pub.techne.draft.statement` about the org carrying `locations` (a site the org's author did not state), this replaces `pub.techne.draft.orgAtPlace`. */
|
|
59
59
|
locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationHthree.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<PubTechneDraftLocationEntry.Main> | {
|
|
60
60
|
$type: string;
|
|
61
61
|
})[];
|
|
@@ -21,7 +21,7 @@ export interface Main {
|
|
|
21
21
|
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.statement", "main">;
|
|
22
22
|
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
23
23
|
export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
|
|
24
|
-
/** Where the subject is, as the writer of the statement says, for a subject of any type. It counts only as the view decides: the subject's own locations win, and a statement fills in only where the subject states no location of that kind, or (with `basis`) gives a position to a subject's entry that has none. A statement the subject's own author writes counts as the subject's own locations. A `basis` equal to the subject record's CID (a legacy claim) counts for any own entry of that kind with no position, while the subject is still that version. When several claims compete for one slot (the same kind, and the same `basis` or none), one counts: the finest grain wins, then the newest, then the lowest source URI; the others are conflicts. On a type whose query document reads its entries as sites (`entries: sites`, as on an org), a claim entry that names no own entry (no `basis`, or a legacy `basis` while the subject states no location of that kind) is its own site: it counts beside every other such entry and competes with none. A claim that names an own entry still competes for that entry, and a subject that states a location of that kind still bars a claim with no `basis`. Read as written, every writer's claim is weighed; curated, only the subject's author's and those of writers the commons root endorses. */
|
|
24
|
+
/** Where the subject is, as the writer of the statement says, for a subject of any type. It counts only as the view decides: the subject's own locations win, and a statement fills in only where the subject states no location of that kind, or (with `basis`) gives a position to a subject's entry that has none. A statement the subject's own author writes counts as the subject's own locations. A `basis` equal to the subject record's CID (a legacy claim) counts for any own entry of that kind with no position, while the subject is still that version. When several claims compete for one slot (the same kind, and the same `basis` or none), one counts: the finest grain wins, then the newest, then the lowest source URI; the others are conflicts. On a type whose query document reads its entries as sites (`entries: sites`, as on an org), a claim entry that names no own entry (no `basis`, or a legacy `basis` while the subject states no location of that kind) is its own site: it counts beside every other such entry and competes with none. A claim that names an own entry still competes for that entry, and a subject that states a location of that kind still bars a claim with no `basis`. Read as written, every writer's claim is weighed; curated, only the subject's author's and those of writers the commons root endorses. The commons curator makes a curated copy of a statement carrying `locations` only when its subject's type reads its entries as sites (an org; never an event or a place) and the statement's author is one the root endorses for statements: the copy is about the curated org and written by the org's curator, so it counts as the org's own locations. */
|
|
25
25
|
export interface Locations {
|
|
26
26
|
$type?: 'pub.techne.draft.statement#locations';
|
|
27
27
|
/** Entries as in the subject's own `locations` field (lexicon naming register). */
|
package/dist/query/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export type QueryNode = {
|
|
|
43
43
|
readonly [role: string]: Condition | readonly QueryNode[];
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
|
-
* Which public records a branch reads; every list names one,
|
|
46
|
+
* Which public records a branch reads; every list names one, and the types require it (the `view` property of `pub.techne.draft.query` and its `#branch`):
|
|
47
47
|
* - `curated`: the commons' listed records, one curated record per thing (merged from its sources by a curator
|
|
48
48
|
* the commons root trusts), moderated, not hidden; an event only inside the supported areas. A type no curator
|
|
49
49
|
* covers is refused with `NotCurated`, naming the type, never answered as an empty list.
|
|
@@ -71,7 +71,8 @@ export interface QueryOptions {
|
|
|
71
71
|
/** A `pub.techne.draft.query`, as data (the platform validates it). Every branch names its {@link View}: `view`
|
|
72
72
|
* beside `where` names it for every branch of the `where` (each child of a top-level `any` too), and the `any`
|
|
73
73
|
* form, `{ any: [{ view, where }, …] }`, one per branch (an app's feed: curated events and its own records as
|
|
74
|
-
* written, in one list).
|
|
74
|
+
* written, in one list). The platform answers a query naming no view the way it did before views through
|
|
75
|
+
* 2027-03-01 (UTC) and refuses it with `ViewRequired` from 2027-03-02. */
|
|
75
76
|
export type Query = QueryOptions & ({
|
|
76
77
|
readonly view: View;
|
|
77
78
|
readonly where: QueryNode;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/react/sign-in — the Techne sign-in form and the "Sign in with Techne" button as React components:
|
|
3
|
+
* `techne-sdk/sign-in`'s {@link mountSignIn} and {@link mountSignInButton} in a `<div>` of their own.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <SignInForm clientId="https://cafes.example/oauth-client-metadata.json" appName="Cafés" logo="/logo.png" />
|
|
7
|
+
* <SignInButton clientId={clientId} theme="light" size="small" />
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Its own subpath, so `techne-sdk/react` still loads no OAuth client. The form mounts again when an option
|
|
11
|
+
* changes; `onError` and `onClick` are read when called, so a new function each render does not remount it.
|
|
12
|
+
*/
|
|
13
|
+
import { type CSSProperties } from 'react';
|
|
14
|
+
import { type SignInButtonOptions, type SignInFormOptions } from '../sign-in/index.js';
|
|
15
|
+
/** The `<div>` the form or the button is mounted in. */
|
|
16
|
+
interface Box {
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
export type SignInFormProps = SignInFormOptions & Box;
|
|
21
|
+
export type SignInButtonProps = SignInButtonOptions & Box;
|
|
22
|
+
/** The sign-in form (`techne-sdk/sign-in`'s `mountSignIn`). */
|
|
23
|
+
export declare function SignInForm(props: SignInFormProps): import("react").DetailedReactHTMLElement<{
|
|
24
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
25
|
+
className: string | undefined;
|
|
26
|
+
style: CSSProperties | undefined;
|
|
27
|
+
}, HTMLDivElement>;
|
|
28
|
+
/** The "Sign in with Techne" button (`techne-sdk/sign-in`'s `mountSignInButton`). */
|
|
29
|
+
export declare function SignInButton(props: SignInButtonProps): import("react").DetailedReactHTMLElement<{
|
|
30
|
+
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
31
|
+
className: string | undefined;
|
|
32
|
+
style: CSSProperties | undefined;
|
|
33
|
+
}, HTMLDivElement>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/react/sign-in — the Techne sign-in form and the "Sign in with Techne" button as React components:
|
|
3
|
+
* `techne-sdk/sign-in`'s {@link mountSignIn} and {@link mountSignInButton} in a `<div>` of their own.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <SignInForm clientId="https://cafes.example/oauth-client-metadata.json" appName="Cafés" logo="/logo.png" />
|
|
7
|
+
* <SignInButton clientId={clientId} theme="light" size="small" />
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Its own subpath, so `techne-sdk/react` still loads no OAuth client. The form mounts again when an option
|
|
11
|
+
* changes; `onError` and `onClick` are read when called, so a new function each render does not remount it.
|
|
12
|
+
*/
|
|
13
|
+
import { createElement, useEffect, useLayoutEffect, useRef } from 'react';
|
|
14
|
+
import { mountSignIn, mountSignInButton } from '../sign-in/index.js';
|
|
15
|
+
/** Mount with `mount` in a div, again when the options (but the callbacks) change. `callbacks` and `mount` are
|
|
16
|
+
* module constants; the options are rebuilt from `key`, so the effect's dependencies are complete. */
|
|
17
|
+
function useMounted(props, callbacks, mount) {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const latest = useRef(props);
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
latest.current = props;
|
|
22
|
+
});
|
|
23
|
+
const { className, style, ...rest } = props;
|
|
24
|
+
const options = { ...rest };
|
|
25
|
+
for (const k of callbacks)
|
|
26
|
+
delete options[k];
|
|
27
|
+
// Whether each callback is given changes what the mount does (a button with onClick starts no sign-in).
|
|
28
|
+
const key = JSON.stringify([options, callbacks.map((k) => props[k] !== undefined)]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const el = ref.current;
|
|
31
|
+
if (!el)
|
|
32
|
+
return;
|
|
33
|
+
const [o, given] = JSON.parse(key);
|
|
34
|
+
callbacks.forEach((k, i) => {
|
|
35
|
+
if (given[i])
|
|
36
|
+
o[k] = (...args) => latest.current[k]?.(...args);
|
|
37
|
+
});
|
|
38
|
+
const m = mount(el, o);
|
|
39
|
+
return () => m.unmount();
|
|
40
|
+
}, [key, callbacks, mount]);
|
|
41
|
+
return createElement('div', { ref, className, style });
|
|
42
|
+
}
|
|
43
|
+
const FORM_CALLBACKS = ['onError'];
|
|
44
|
+
const BUTTON_CALLBACKS = ['onError', 'onClick'];
|
|
45
|
+
/** The sign-in form (`techne-sdk/sign-in`'s `mountSignIn`). */
|
|
46
|
+
export function SignInForm(props) {
|
|
47
|
+
return useMounted(props, FORM_CALLBACKS, mountSignIn);
|
|
48
|
+
}
|
|
49
|
+
/** The "Sign in with Techne" button (`techne-sdk/sign-in`'s `mountSignInButton`). */
|
|
50
|
+
export function SignInButton(props) {
|
|
51
|
+
return useMounted(props, BUTTON_CALLBACKS, mountSignInButton);
|
|
52
|
+
}
|
package/dist/session/phone.d.ts
CHANGED
|
@@ -39,8 +39,8 @@ export interface FinishPhoneSignInOptions extends PhoneSignInOptions {
|
|
|
39
39
|
/**
|
|
40
40
|
* Step 1: ask the door for its endpoints, make the DPoP key and the PKCE pair, and start the sign-in (the
|
|
41
41
|
* platform texts the code). Rejects with the platform's refusal as an {@link OwnSessionError}:
|
|
42
|
-
* `
|
|
43
|
-
* (`retryAfter`), `InvalidRequest`.
|
|
42
|
+
* `Unavailable` (no code could be sent: try again; an older platform says `OwnSessionUnavailable`),
|
|
43
|
+
* `RateLimitExceeded` (`retryAfter`), `InvalidRequest`.
|
|
44
44
|
*/
|
|
45
45
|
export declare function startPhoneSignIn(o: PhoneSignInOptions & {
|
|
46
46
|
phone: string;
|
|
@@ -50,10 +50,11 @@ export declare function startPhoneSignIn(o: PhoneSignInOptions & {
|
|
|
50
50
|
* platform uses only if a check refuses the sign-in) are signed with the latest nonce; a `UseDpopNonce`
|
|
51
51
|
* answer with a new nonce is signed again and sent with the same code (the platform has not spent it), up to
|
|
52
52
|
* twice (the code step and the token step may each ask). `pending.dpopNonce` keeps the latest nonce, so a
|
|
53
|
-
* retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and
|
|
54
|
-
*
|
|
55
|
-
* again), `CodeExpired` (start again),
|
|
56
|
-
* `
|
|
53
|
+
* retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and `created`: the
|
|
54
|
+
* platform records the account for the first time (normally a new number; the app asks for a name next).
|
|
55
|
+
* Rejects with the platform's refusal: `InvalidRequest` (wrong code: try again), `CodeExpired` (start again),
|
|
56
|
+
* `MethodFrozen`, `AccountUnavailable` (the number can't sign in here), `NumberRemoved` (sign in with the
|
|
57
|
+
* current number), `RateLimitExceeded`, `Unavailable`.
|
|
57
58
|
*/
|
|
58
59
|
export declare function finishPhoneSignIn(pending: PendingPhoneSignIn, code: string, o: FinishPhoneSignInOptions): Promise<{
|
|
59
60
|
session: OwnSessionData;
|
package/dist/session/phone.js
CHANGED
|
@@ -27,8 +27,8 @@ function ownAnswer(nsid, own) {
|
|
|
27
27
|
/**
|
|
28
28
|
* Step 1: ask the door for its endpoints, make the DPoP key and the PKCE pair, and start the sign-in (the
|
|
29
29
|
* platform texts the code). Rejects with the platform's refusal as an {@link OwnSessionError}:
|
|
30
|
-
* `
|
|
31
|
-
* (`retryAfter`), `InvalidRequest`.
|
|
30
|
+
* `Unavailable` (no code could be sent: try again; an older platform says `OwnSessionUnavailable`),
|
|
31
|
+
* `RateLimitExceeded` (`retryAfter`), `InvalidRequest`.
|
|
32
32
|
*/
|
|
33
33
|
export async function startPhoneSignIn(o) {
|
|
34
34
|
const fetch = fetchOr(o.fetch);
|
|
@@ -54,10 +54,11 @@ export async function startPhoneSignIn(o) {
|
|
|
54
54
|
* platform uses only if a check refuses the sign-in) are signed with the latest nonce; a `UseDpopNonce`
|
|
55
55
|
* answer with a new nonce is signed again and sent with the same code (the platform has not spent it), up to
|
|
56
56
|
* twice (the code step and the token step may each ask). `pending.dpopNonce` keeps the latest nonce, so a
|
|
57
|
-
* retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and
|
|
58
|
-
*
|
|
59
|
-
* again), `CodeExpired` (start again),
|
|
60
|
-
* `
|
|
57
|
+
* retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and `created`: the
|
|
58
|
+
* platform records the account for the first time (normally a new number; the app asks for a name next).
|
|
59
|
+
* Rejects with the platform's refusal: `InvalidRequest` (wrong code: try again), `CodeExpired` (start again),
|
|
60
|
+
* `MethodFrozen`, `AccountUnavailable` (the number can't sign in here), `NumberRemoved` (sign in with the
|
|
61
|
+
* current number), `RateLimitExceeded`, `Unavailable`.
|
|
61
62
|
*/
|
|
62
63
|
export async function finishPhoneSignIn(pending, code, o) {
|
|
63
64
|
const fetch = fetchOr(o.fetch);
|
package/dist/session/relay.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `SessionEnded` (sign in again), `NetworkError` (no answer), `WrongAccount` (the tokens name another DID),
|
|
8
8
|
* `InvalidResponse` (an answer without what the lexicon promises). */
|
|
9
9
|
export declare class OwnSessionError extends Error {
|
|
10
|
-
/** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `
|
|
10
|
+
/** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `Unavailable`, `RateLimitExceeded`, ...) or the SDK's. */
|
|
11
11
|
readonly code: string;
|
|
12
12
|
/** The HTTP status, when there was an answer. */
|
|
13
13
|
readonly status?: number;
|
package/dist/session/relay.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `SessionEnded` (sign in again), `NetworkError` (no answer), `WrongAccount` (the tokens name another DID),
|
|
8
8
|
* `InvalidResponse` (an answer without what the lexicon promises). */
|
|
9
9
|
export class OwnSessionError extends Error {
|
|
10
|
-
/** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `
|
|
10
|
+
/** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `Unavailable`, `RateLimitExceeded`, ...) or the SDK's. */
|
|
11
11
|
code;
|
|
12
12
|
/** The HTTP status, when there was an answer. */
|
|
13
13
|
status;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type SignInOptions } from '../auth/index.js';
|
|
2
|
+
/** What a sign-in from the form or the button carries: everything {@link signIn} takes but who is signing in. */
|
|
3
|
+
export type SignInFormClient = Omit<SignInOptions, 'handle' | 'email' | 'phone' | 'otherWays' | 'signUp'>;
|
|
4
|
+
/** What {@link mountSignIn} takes. */
|
|
5
|
+
export interface SignInFormOptions extends SignInFormClient {
|
|
6
|
+
/** The app's name, shown beside its logo and in the line under "Sign in". */
|
|
7
|
+
appName: string;
|
|
8
|
+
/** The app's logo: an image URL (a square, shown 44 px with rounded corners). None: the name alone. */
|
|
9
|
+
logo?: string;
|
|
10
|
+
/** Called when a sign-in could not start (the PDS could not be reached, say); the form also says so. */
|
|
11
|
+
onError?: (error: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/** What {@link mountSignInButton} takes. */
|
|
14
|
+
export interface SignInButtonOptions extends SignInFormClient {
|
|
15
|
+
/** `dark`: black, for light backgrounds (the default). `light`: white with a black edge, for dark ones. */
|
|
16
|
+
theme?: 'dark' | 'light';
|
|
17
|
+
/** `medium`: 44 px tall (the default). `small`: 36 px, for a navigation bar. */
|
|
18
|
+
size?: 'medium' | 'small';
|
|
19
|
+
/** Called instead of {@link signIn} on a click (to show the form, say). */
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
/** Called when the sign-in could not start. */
|
|
22
|
+
onError?: (error: unknown) => void;
|
|
23
|
+
}
|
|
24
|
+
/** A mounted form or button. */
|
|
25
|
+
export interface Mounted {
|
|
26
|
+
/** Remove it from the page. */
|
|
27
|
+
unmount(): void;
|
|
28
|
+
}
|
|
29
|
+
/** Mount the sign-in form in `target` (appended to it). See the module doc for what it shows and does. */
|
|
30
|
+
export declare function mountSignIn(target: Element, options: SignInFormOptions): Mounted;
|
|
31
|
+
/** Mount the "Sign in with Techne" button in `target` (appended to it). A click starts {@link signIn} with no
|
|
32
|
+
* handle (the Techne sign-in page's first step), or calls `onClick` instead. */
|
|
33
|
+
export declare function mountSignInButton(target: Element, options: SignInButtonOptions): Mounted;
|