techne-sdk 0.6.0 → 0.8.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 +48 -5
- package/README.md +51 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +5 -3
- package/dist/auth/placement.gen.d.ts +1 -1
- package/dist/auth/placement.gen.js +4 -0
- package/dist/catalog/catalog.gen.d.ts +2 -2
- package/dist/catalog/catalog.gen.js +1394 -130
- package/dist/generated/index.d.ts +129 -0
- package/dist/generated/index.js +170 -0
- package/dist/generated/lexicons.d.ts +954 -134
- package/dist/generated/lexicons.js +511 -61
- package/dist/generated/nsid.d.ts +16 -1
- package/dist/generated/nsid.js +16 -1
- package/dist/generated/nsid.json +16 -1
- package/dist/generated/records.d.ts +148 -140
- package/dist/generated/types/app/certified/defs.d.ts +20 -0
- package/dist/generated/types/app/certified/defs.js +18 -0
- package/dist/generated/types/app/certified/signature/defs.d.ts +29 -0
- package/dist/generated/types/app/certified/signature/defs.js +18 -0
- package/dist/generated/types/org/hypercerts/funding/receipt.d.ts +56 -0
- package/dist/generated/types/org/hypercerts/funding/receipt.js +19 -0
- package/dist/generated/types/pub/techne/draft/financials.d.ts +26 -0
- package/dist/generated/types/pub/techne/draft/financials.js +12 -0
- package/dist/generated/types/pub/techne/draft/identity/createCollective.d.ts +5 -0
- package/dist/generated/types/pub/techne/draft/identity/createCollective.js +7 -0
- package/dist/generated/types/pub/techne/draft/identity/defs.d.ts +1 -1
- package/dist/generated/types/pub/techne/draft/identity/manageMethods.d.ts +4 -1
- package/dist/generated/types/pub/techne/draft/org.d.ts +55 -25
- package/dist/generated/types/pub/techne/draft/org.js +12 -5
- package/dist/generated/types/pub/techne/draft/orgAtPlace.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/orgAtPlace.js +12 -0
- package/dist/generated/types/pub/techne/draft/statement.d.ts +19 -0
- package/dist/generated/types/pub/techne/draft/statement.js +12 -0
- package/dist/session/dpop.d.ts +49 -0
- package/dist/session/dpop.js +105 -0
- package/dist/session/index.d.ts +22 -0
- package/dist/session/index.js +22 -0
- package/dist/session/own-session.d.ts +169 -0
- package/dist/session/own-session.js +364 -0
- package/dist/session/phone.d.ts +79 -0
- package/dist/session/phone.js +179 -0
- package/dist/session/relay.d.ts +69 -0
- package/dist/session/relay.js +120 -0
- package/dist/wasm/techne-wasm.gen.js +1 -1
- package/dist/wasm/techne-wasm2js.gen.js +23340 -23255
- package/package.json +10 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
import { type $Typed } from '../../../../util.js';
|
|
6
|
+
import type * as AppCertifiedDefs from '../../../app/certified/defs.js';
|
|
7
|
+
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
8
|
+
import type * as AppCertifiedSignatureDefs from '../../../app/certified/signature/defs.js';
|
|
9
|
+
export interface Main {
|
|
10
|
+
$type: 'org.hypercerts.funding.receipt';
|
|
11
|
+
from?: $Typed<Text> | $Typed<AppCertifiedDefs.Did> | $Typed<ComAtprotoRepoStrongRef.Main> | {
|
|
12
|
+
$type: string;
|
|
13
|
+
};
|
|
14
|
+
to: $Typed<Text> | $Typed<AppCertifiedDefs.Did> | $Typed<ComAtprotoRepoStrongRef.Main> | {
|
|
15
|
+
$type: string;
|
|
16
|
+
};
|
|
17
|
+
via?: $Typed<Text> | $Typed<AppCertifiedDefs.Did> | $Typed<ComAtprotoRepoStrongRef.Main> | {
|
|
18
|
+
$type: string;
|
|
19
|
+
};
|
|
20
|
+
/** What the payment is: a donation (a gift from the sender), a match (funds a matching pool allocated on the strength of other gifts) or a grant (funds awarded through a selection process). Values beyond the known set are permitted. Omit if unknown. */
|
|
21
|
+
type?: 'donation' | 'match' | 'grant' | (string & {});
|
|
22
|
+
/** Gross amount the sender paid, before fees, as a numeric string (e.g. '1000.50'). Omit if unknown, and set netAmount instead. */
|
|
23
|
+
amount?: string;
|
|
24
|
+
/** Currency of amount: an ISO 4217 code for fiat (e.g. EUR), a token ticker for digital assets (e.g. USDC). This is what marks the funds as fiat or digital. Set it whenever amount is set. */
|
|
25
|
+
currency?: string;
|
|
26
|
+
/** What the recipient received after fees and conversion, as a numeric string in netCurrency. */
|
|
27
|
+
netAmount?: string;
|
|
28
|
+
/** Currency of netAmount: an ISO 4217 code for fiat, a token ticker for digital assets. Set it whenever netAmount is set. */
|
|
29
|
+
netCurrency?: string;
|
|
30
|
+
/** How the sender paid. Use 'payment_processor' only when the underlying method is unknown. */
|
|
31
|
+
paymentRail?: 'onchain' | 'bank_transfer' | 'card' | 'direct_debit' | 'mobile_money' | 'payment_processor' | 'cash' | 'check' | (string & {});
|
|
32
|
+
/** Where transactionId can be looked up: the chain for onchain payments, preferably as a CAIP-2 ID (e.g. 'eip155:1'), otherwise the processor or scheme (e.g. stripe, sepa). Set it whenever transactionId is a transaction hash. */
|
|
33
|
+
paymentNetwork?: string;
|
|
34
|
+
/** ID of the sender's payment, not of a platform's later payout: a transaction hash for onchain payments, otherwise the processor's or scheme's reference. Receipts are public: prefer opaque processor IDs to bank references, and note that a hash reveals the sender's wallet even when from is omitted. */
|
|
35
|
+
transactionId?: string;
|
|
36
|
+
for?: ComAtprotoRepoStrongRef.Main;
|
|
37
|
+
/** Optional notes or additional context for this funding receipt. */
|
|
38
|
+
notes?: string;
|
|
39
|
+
/** Timestamp when the payment occurred. */
|
|
40
|
+
occurredAt?: string;
|
|
41
|
+
/** Client-declared timestamp when this receipt record was created. */
|
|
42
|
+
createdAt: string;
|
|
43
|
+
signatures?: AppCertifiedSignatureDefs.List;
|
|
44
|
+
[k: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "org.hypercerts.funding.receipt", "main">;
|
|
47
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
48
|
+
export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
|
|
49
|
+
/** A free-text string value (e.g. a display name, wallet address, or other identifier). */
|
|
50
|
+
export interface Text {
|
|
51
|
+
$type?: 'org.hypercerts.funding.receipt#text';
|
|
52
|
+
/** The string value. */
|
|
53
|
+
value: string;
|
|
54
|
+
}
|
|
55
|
+
export declare function isText<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "org.hypercerts.funding.receipt", "text">;
|
|
56
|
+
export declare function validateText<V>(v: V): ValidationResult<Text & V>;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 = 'org.hypercerts.funding.receipt';
|
|
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, };
|
|
13
|
+
const hashText = 'text';
|
|
14
|
+
export function isText(v) {
|
|
15
|
+
return is$typed(v, id, hashText);
|
|
16
|
+
}
|
|
17
|
+
export function validateText(v) {
|
|
18
|
+
return validate(v, id, hashText);
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
6
|
+
export interface Main {
|
|
7
|
+
$type: 'pub.techne.draft.financials';
|
|
8
|
+
subject: ComAtprotoRepoStrongRef.Main;
|
|
9
|
+
/** The tax year the figures cover, as the filing names it. */
|
|
10
|
+
taxYear: number;
|
|
11
|
+
/** The last day of the tax year (YYYY-MM-DD) when the filing states it; a fiscal year need not end in December. */
|
|
12
|
+
periodEnd?: string;
|
|
13
|
+
/** Total revenue for the year, in whole units of `currency`, as the filing reports it. May be negative. */
|
|
14
|
+
revenue?: number;
|
|
15
|
+
/** Total expenses for the year, in whole units of `currency`, as the filing reports it. May be negative. */
|
|
16
|
+
expenses?: number;
|
|
17
|
+
/** Total assets at the end of the year, in whole units of `currency`, as the filing reports it. May be negative. */
|
|
18
|
+
assets?: number;
|
|
19
|
+
/** ISO 4217 code of the amounts. */
|
|
20
|
+
currency: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
[k: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.financials", "main">;
|
|
25
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
26
|
+
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.financials';
|
|
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, };
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { HeadersMap, XRPCError } from '@atproto/xrpc';
|
|
5
5
|
export type QueryParams = {};
|
|
6
6
|
export interface InputSchema {
|
|
7
|
+
/** Who sees the founding membership: `members` (placed in the collective's member space, `pub.techne.draft.space.collective.member/self`, seen by its members) or `public` (a public record). */
|
|
8
|
+
founderMembershipVisibility?: 'public' | 'members' | (string & {});
|
|
7
9
|
}
|
|
8
10
|
export interface OutputSchema {
|
|
9
11
|
/** The new collective. */
|
|
@@ -22,6 +24,9 @@ export interface Response {
|
|
|
22
24
|
headers: HeadersMap;
|
|
23
25
|
data: OutputSchema;
|
|
24
26
|
}
|
|
27
|
+
export declare class InvalidRequestError extends XRPCError {
|
|
28
|
+
constructor(src: XRPCError);
|
|
29
|
+
}
|
|
25
30
|
export declare class RateLimitExceededError extends XRPCError {
|
|
26
31
|
constructor(src: XRPCError);
|
|
27
32
|
}
|
|
@@ -6,6 +6,11 @@ import { validate as _validate } from '../../../../../lexicons.js';
|
|
|
6
6
|
import { is$typed as _is$typed, } from '../../../../../util.js';
|
|
7
7
|
const is$typed = _is$typed, validate = _validate;
|
|
8
8
|
const id = 'pub.techne.draft.identity.createCollective';
|
|
9
|
+
export class InvalidRequestError extends XRPCError {
|
|
10
|
+
constructor(src) {
|
|
11
|
+
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
9
14
|
export class RateLimitExceededError extends XRPCError {
|
|
10
15
|
constructor(src) {
|
|
11
16
|
super(src.status, src.error, src.message, src.headers, { cause: src });
|
|
@@ -13,6 +18,8 @@ export class RateLimitExceededError extends XRPCError {
|
|
|
13
18
|
}
|
|
14
19
|
export function toKnownErr(e) {
|
|
15
20
|
if (e instanceof XRPCError) {
|
|
21
|
+
if (e.error === 'InvalidRequest')
|
|
22
|
+
return new InvalidRequestError(e);
|
|
16
23
|
if (e.error === 'RateLimitExceeded')
|
|
17
24
|
return new RateLimitExceededError(e);
|
|
18
25
|
}
|
|
@@ -17,7 +17,7 @@ export interface MethodView {
|
|
|
17
17
|
/** The method's id: the binding id (the credential's record key) of an email or phone, else the platform's id for it. Names the method in unlinkMethod and manageMethods. */
|
|
18
18
|
bid: string;
|
|
19
19
|
type: 'email' | 'phone' | 'passkey' | 'nostr' | 'recoveryCodes' | (string & {});
|
|
20
|
-
/** The channel with most of it hidden, e.g. `j•••@example.com`,
|
|
20
|
+
/** The channel with most of it hidden, e.g. `j•••@example.com`, `••• ••• 4567`; a passkey's or Nostr key's label; `Recovery codes (n left)`. */
|
|
21
21
|
masked: string;
|
|
22
22
|
/** An email's full address or a phone's full number (E.164). Sent only by identity.manageMethods `list`, to the identity PDS, for the owner's own account page; never in identity.listMethods, signInMethods or a notice. Absent on a passkey, Nostr key or recovery codes. */
|
|
23
23
|
value?: string;
|
|
@@ -228,13 +228,16 @@ export interface NoticeTo {
|
|
|
228
228
|
}
|
|
229
229
|
export declare function isNoticeTo<V>(v: V): v is import("../../../../../util.js").$TypedObject<V, "pub.techne.draft.identity.manageMethods", "noticeTo">;
|
|
230
230
|
export declare function validateNoticeTo<V>(v: V): ValidationResult<NoticeTo & V>;
|
|
231
|
-
/** One way to sign in, as a page may show it before anyone has signed in:
|
|
231
|
+
/** One way to sign in, as a page may show it before anyone has signed in: masked, never its full value (though an address whose local part is one character is fully implied). */
|
|
232
232
|
export interface SignInMethod {
|
|
233
233
|
$type?: 'pub.techne.draft.identity.manageMethods#signInMethod';
|
|
234
234
|
/** The method id (for `sendTo`, and the PDS's own passkey or Nostr challenge). */
|
|
235
235
|
id: string;
|
|
236
236
|
type: 'email' | 'phone' | 'passkey' | 'nostr' | (string & {});
|
|
237
|
+
/** For any page, one reached by typing a handle included: an email keeps its first character and, at a common email provider, its domain (`a•••@gmail.com`), at any other domain only the domain's last part (`a•••@•••.dev`; `a•••@•••` for a domain with no dot); a phone its last two digits (`•••• 97`); a passkey or Nostr key its label. */
|
|
237
238
|
display: string;
|
|
239
|
+
/** Only for the PDS's chooser of the accounts already signed in on that browser, never for a page reached by typing a handle: an email keeps its first character and its whole domain (`a•••@example.dev`), a phone its last four digits (`••• ••• 4242`); a passkey or Nostr key its label, as `display`. Present exactly when `display` is. Absent from a platform older than this field: use `display`. */
|
|
240
|
+
displayDevice?: string;
|
|
238
241
|
}
|
|
239
242
|
export declare function isSignInMethod<V>(v: V): v is import("../../../../../util.js").$TypedObject<V, "pub.techne.draft.identity.manageMethods", "signInMethod">;
|
|
240
243
|
export declare function validateSignInMethod<V>(v: V): ValidationResult<SignInMethod & V>;
|
|
@@ -2,41 +2,71 @@
|
|
|
2
2
|
* GENERATED CODE - DO NOT MODIFY
|
|
3
3
|
*/
|
|
4
4
|
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
import { type $Typed } from '../../../../util.js';
|
|
6
|
+
import type * as CommunityLexiconLocationGeo from '../../../community/lexicon/location/geo.js';
|
|
5
7
|
import type * as CommunityLexiconLocationAddress from '../../../community/lexicon/location/address.js';
|
|
8
|
+
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
6
9
|
export interface Main {
|
|
7
10
|
$type: 'pub.techne.draft.org';
|
|
8
|
-
/** The organization's
|
|
11
|
+
/** The organization's name as its registry records it. */
|
|
9
12
|
name: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
url?: string;
|
|
18
|
-
/** E.164 phone number. From the almanac `phone` attribute. */
|
|
19
|
-
telephone?: string;
|
|
20
|
-
/** Public contact address. From the almanac `email` attribute, when a merged peg carries one. No atproto lexicon "email" format token exists (atrium-codegen's fixed format enum has no such variant) — unlike the almanac's own value_schema, this field carries no format assertion, only the length bound. */
|
|
21
|
-
email?: string;
|
|
22
|
-
/** Formation date — year, year-month, or full date (shape ^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$ — atproto lexicon strings carry no pattern property, so the publisher enforces this before write), as the source states it. From the almanac `founded` attribute. */
|
|
13
|
+
/** Ids the organization has in other registries: `{scheme: "ein", value}` (9 digits, no dash), `{scheme: "co-sos", value}`. Identity between two org records is a `pub.techne.draft.sameAs`, never a field here; an EIN is its strongest basis. */
|
|
14
|
+
identifiers?: SchemeValue[];
|
|
15
|
+
/** Classification codes per scheme: `irs-ntee`, `irs-subsection`, `co-sos-entity-type`. */
|
|
16
|
+
category?: SchemeValue[];
|
|
17
|
+
/** Registry standing per scheme (`irs`, `co-sos`). A closed organization keeps its record with its status; it is never deleted. */
|
|
18
|
+
status?: SchemeValue[];
|
|
19
|
+
/** Formation date as the source states it: year, year-month or full date (shape ^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$; atproto strings carry no pattern, so the writer enforces it). */
|
|
23
20
|
founded?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
/** Prose about the organization: for a nonprofit, the mission and program text it filed with the IRS (Form 990). Public. */
|
|
22
|
+
description?: string;
|
|
23
|
+
/** The organization's own website, absolute http(s). */
|
|
24
|
+
url?: string;
|
|
25
|
+
/** Public phone number, E.164. */
|
|
26
|
+
phone?: string;
|
|
27
|
+
/** Where the organization is: a point, an address or a place record. Never a mailing address: a registry's address is often an organizer's home, so it is not published. An organization's office or storefront at a commons place is a `pub.techne.draft.orgAtPlace` record, not an entry here. */
|
|
28
|
+
locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | {
|
|
29
|
+
$type: string;
|
|
30
|
+
})[];
|
|
29
31
|
createdAt: string;
|
|
30
32
|
[k: string]: unknown;
|
|
31
33
|
}
|
|
32
34
|
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.org", "main">;
|
|
33
35
|
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
34
36
|
export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
|
|
35
|
-
/**
|
|
36
|
-
export interface
|
|
37
|
-
$type?: 'pub.techne.draft.org#
|
|
37
|
+
/** Some of an org's own fields, carried by a `pub.techne.draft.statement` about an org record someone else wrote (the subject). Every property is the main record's property of the same name, with the same shape; none is required. */
|
|
38
|
+
export interface Fields {
|
|
39
|
+
$type?: 'pub.techne.draft.org#fields';
|
|
40
|
+
/** The organization's name as its registry records it. */
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Ids the organization has in other registries: `{scheme: "ein", value}` (9 digits, no dash), `{scheme: "co-sos", value}`. Identity between two org records is a `pub.techne.draft.sameAs`, never a field here; an EIN is its strongest basis. */
|
|
43
|
+
identifiers?: SchemeValue[];
|
|
44
|
+
/** Classification codes per scheme: `irs-ntee`, `irs-subsection`, `co-sos-entity-type`. */
|
|
45
|
+
category?: SchemeValue[];
|
|
46
|
+
/** Registry standing per scheme (`irs`, `co-sos`). A closed organization keeps its record with its status; it is never deleted. */
|
|
47
|
+
status?: SchemeValue[];
|
|
48
|
+
/** Formation date as the source states it: year, year-month or full date (shape ^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$; atproto strings carry no pattern, so the writer enforces it). */
|
|
49
|
+
founded?: string;
|
|
50
|
+
/** Prose about the organization: for a nonprofit, the mission and program text it filed with the IRS (Form 990). Public. */
|
|
51
|
+
description?: string;
|
|
52
|
+
/** The organization's own website, absolute http(s). */
|
|
53
|
+
url?: string;
|
|
54
|
+
/** Public phone number, E.164. */
|
|
55
|
+
phone?: string;
|
|
56
|
+
/** Where the organization is: a point, an address or a place record. Never a mailing address: a registry's address is often an organizer's home, so it is not published. An organization's office or storefront at a commons place is a `pub.techne.draft.orgAtPlace` record, not an entry here. */
|
|
57
|
+
locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | {
|
|
58
|
+
$type: string;
|
|
59
|
+
})[];
|
|
60
|
+
}
|
|
61
|
+
export declare function isFields<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.org", "fields">;
|
|
62
|
+
export declare function validateFields<V>(v: V): ValidationResult<Fields & V>;
|
|
63
|
+
/** One code in a named scheme: an identifier (`identifiers`), a classification (`category`) or a standing (`status`). `scheme` names the registry or code list, `value` is the code as that registry writes it. */
|
|
64
|
+
export interface SchemeValue {
|
|
65
|
+
$type?: 'pub.techne.draft.org#schemeValue';
|
|
66
|
+
/** The registry or code list, e.g. `ein`, `co-sos`, `irs-ntee`, `irs-subsection`, `co-sos-entity-type`, `irs`. */
|
|
38
67
|
scheme: string;
|
|
39
|
-
code
|
|
68
|
+
/** The code as the registry writes it, e.g. an EIN as 9 digits with no dash. */
|
|
69
|
+
value: string;
|
|
40
70
|
}
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
71
|
+
export declare function isSchemeValue<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.org", "schemeValue">;
|
|
72
|
+
export declare function validateSchemeValue<V>(v: V): ValidationResult<SchemeValue & V>;
|
|
@@ -10,10 +10,17 @@ export function validateMain(v) {
|
|
|
10
10
|
return validate(v, id, hashMain, true);
|
|
11
11
|
}
|
|
12
12
|
export { isMain as isRecord, validateMain as validateRecord, };
|
|
13
|
-
const
|
|
14
|
-
export function
|
|
15
|
-
return is$typed(v, id,
|
|
13
|
+
const hashFields = 'fields';
|
|
14
|
+
export function isFields(v) {
|
|
15
|
+
return is$typed(v, id, hashFields);
|
|
16
16
|
}
|
|
17
|
-
export function
|
|
18
|
-
return validate(v, id,
|
|
17
|
+
export function validateFields(v) {
|
|
18
|
+
return validate(v, id, hashFields);
|
|
19
|
+
}
|
|
20
|
+
const hashSchemeValue = 'schemeValue';
|
|
21
|
+
export function isSchemeValue(v) {
|
|
22
|
+
return is$typed(v, id, hashSchemeValue);
|
|
23
|
+
}
|
|
24
|
+
export function validateSchemeValue(v) {
|
|
25
|
+
return validate(v, id, hashSchemeValue);
|
|
19
26
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
6
|
+
export interface Main {
|
|
7
|
+
$type: 'pub.techne.draft.orgAtPlace';
|
|
8
|
+
subject: ComAtprotoRepoStrongRef.Main;
|
|
9
|
+
place: ComAtprotoRepoStrongRef.Main;
|
|
10
|
+
/** What the place is to the organization. Values beyond the known set are permitted. */
|
|
11
|
+
role?: 'office' | 'storefront' | (string & {});
|
|
12
|
+
createdAt: string;
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.orgAtPlace", "main">;
|
|
16
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
17
|
+
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.orgAtPlace';
|
|
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,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED CODE - DO NOT MODIFY
|
|
3
|
+
*/
|
|
4
|
+
import { type ValidationResult } from '@atproto/lexicon';
|
|
5
|
+
import { type $Typed } from '../../../../util.js';
|
|
6
|
+
import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
|
|
7
|
+
import type * as PubTechneDraftOrg from './org.js';
|
|
8
|
+
export interface Main {
|
|
9
|
+
$type: 'pub.techne.draft.statement';
|
|
10
|
+
subject: ComAtprotoRepoStrongRef.Main;
|
|
11
|
+
fields: $Typed<PubTechneDraftOrg.Fields> | {
|
|
12
|
+
$type: string;
|
|
13
|
+
};
|
|
14
|
+
createdAt: string;
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.statement", "main">;
|
|
18
|
+
export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
|
|
19
|
+
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.statement';
|
|
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,49 @@
|
|
|
1
|
+
/** A P-256 private key as a JWK (`d` is the secret). Keep it in the app's secure storage, never in a log. */
|
|
2
|
+
export interface DpopKey {
|
|
3
|
+
kty: 'EC';
|
|
4
|
+
crv: 'P-256';
|
|
5
|
+
x: string;
|
|
6
|
+
y: string;
|
|
7
|
+
d: string;
|
|
8
|
+
}
|
|
9
|
+
/** The public half of a {@link DpopKey}: what a proof's header carries. */
|
|
10
|
+
export type DpopPublicKey = Omit<DpopKey, 'd'>;
|
|
11
|
+
/** `bytes` as unpadded base64url. */
|
|
12
|
+
export declare function base64url(bytes: Uint8Array): string;
|
|
13
|
+
/** The bytes of unpadded (or padded) base64url `s`. */
|
|
14
|
+
export declare function fromBase64url(s: string): Uint8Array;
|
|
15
|
+
/** base64url SHA-256 of `s` (UTF-8): a proof's `ath` for token `s`, or the S256 PKCE challenge of verifier `s`. */
|
|
16
|
+
export declare function sha256b64url(s: string): string;
|
|
17
|
+
/** A new P-256 key for DPoP. */
|
|
18
|
+
export declare function generateDpopKey(): DpopKey;
|
|
19
|
+
/** `key` checked to be a P-256 private JWK whose public half matches its secret (a JWK from storage or
|
|
20
|
+
* from the platform's `adoptHeldSession`). */
|
|
21
|
+
export declare function dpopKeyFromJwk(key: unknown): DpopKey;
|
|
22
|
+
/** The public half of `key`. */
|
|
23
|
+
export declare function publicJwk(key: DpopKey): DpopPublicKey;
|
|
24
|
+
/** The RFC 7638 thumbprint of `key` (`jkt`): base64url SHA-256 of its required members in order. */
|
|
25
|
+
export declare function jwkThumbprint(key: DpopPublicKey): string;
|
|
26
|
+
/** A random URL-safe string from `n` random bytes (`jti`, the PKCE verifier). */
|
|
27
|
+
export declare function randomString(n?: number): string;
|
|
28
|
+
/** A PKCE pair (S256): the verifier the app keeps, the challenge it sends. */
|
|
29
|
+
export declare function pkcePair(): {
|
|
30
|
+
verifier: string;
|
|
31
|
+
challenge: string;
|
|
32
|
+
};
|
|
33
|
+
/** `url` without its query and fragment: a proof's `htu` (RFC 9449 section 4.2). */
|
|
34
|
+
export declare function htuOf(url: string): string;
|
|
35
|
+
/** What one proof is for. */
|
|
36
|
+
export interface ProofFor {
|
|
37
|
+
/** The request's method (`POST`, `GET`; `GET` for a WebSocket upgrade). */
|
|
38
|
+
htm: string;
|
|
39
|
+
/** The request's full URL; its query and fragment are dropped ({@link htuOf}). */
|
|
40
|
+
htu: string;
|
|
41
|
+
/** The server's latest DPoP nonce, when it asks for one. */
|
|
42
|
+
nonce?: string;
|
|
43
|
+
/** The access token (or device credential) the proof goes with: its hash becomes `ath`. */
|
|
44
|
+
token?: string;
|
|
45
|
+
/** Unix seconds; now by default. */
|
|
46
|
+
iat?: number;
|
|
47
|
+
}
|
|
48
|
+
/** A DPoP proof (a `dpop+jwt`, ES256) by `key` for one request. Each has a fresh `jti`. */
|
|
49
|
+
export declare function dpopProof(key: DpopKey, p: ProofFor): string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DPoP (RFC 9449) and PKCE (RFC 7636) for a session the app holds itself, in plain JavaScript: P-256 and
|
|
3
|
+
* SHA-256 from `@noble/curves` and `@noble/hashes`, so it runs on Hermes (React Native), which has no
|
|
4
|
+
* `crypto.subtle`. The one thing the host must give is `crypto.getRandomValues` (React Native:
|
|
5
|
+
* `react-native-get-random-values`, imported once at the app's entry).
|
|
6
|
+
*
|
|
7
|
+
* No `Buffer` and no `URL` here either: React Native has neither in full.
|
|
8
|
+
*/
|
|
9
|
+
import { p256 } from '@noble/curves/nist.js';
|
|
10
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
11
|
+
import { randomBytes } from '@noble/hashes/utils.js';
|
|
12
|
+
const B64U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
13
|
+
/** `bytes` as unpadded base64url. */
|
|
14
|
+
export function base64url(bytes) {
|
|
15
|
+
let out = '';
|
|
16
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
17
|
+
const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);
|
|
18
|
+
out += B64U[(n >> 18) & 63] + B64U[(n >> 12) & 63];
|
|
19
|
+
if (i + 1 < bytes.length)
|
|
20
|
+
out += B64U[(n >> 6) & 63];
|
|
21
|
+
if (i + 2 < bytes.length)
|
|
22
|
+
out += B64U[n & 63];
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
/** The bytes of unpadded (or padded) base64url `s`. */
|
|
27
|
+
export function fromBase64url(s) {
|
|
28
|
+
const clean = s.replace(/=+$/, '');
|
|
29
|
+
const out = new Uint8Array(Math.floor((clean.length * 3) / 4));
|
|
30
|
+
let bits = 0;
|
|
31
|
+
let acc = 0;
|
|
32
|
+
let j = 0;
|
|
33
|
+
for (const ch of clean) {
|
|
34
|
+
const v = B64U.indexOf(ch);
|
|
35
|
+
if (v < 0)
|
|
36
|
+
throw new Error('techne-sdk/session: not base64url');
|
|
37
|
+
acc = (acc << 6) | v;
|
|
38
|
+
bits += 6;
|
|
39
|
+
if (bits >= 8) {
|
|
40
|
+
bits -= 8;
|
|
41
|
+
out[j++] = (acc >> bits) & 0xff;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
47
|
+
/** base64url SHA-256 of `s` (UTF-8): a proof's `ath` for token `s`, or the S256 PKCE challenge of verifier `s`. */
|
|
48
|
+
export function sha256b64url(s) {
|
|
49
|
+
return base64url(sha256(utf8(s)));
|
|
50
|
+
}
|
|
51
|
+
/** A new P-256 key for DPoP. */
|
|
52
|
+
export function generateDpopKey() {
|
|
53
|
+
const secret = p256.utils.randomSecretKey();
|
|
54
|
+
return jwkOf(secret);
|
|
55
|
+
}
|
|
56
|
+
function jwkOf(secret) {
|
|
57
|
+
const pub = p256.getPublicKey(secret, false); // 0x04 || x || y
|
|
58
|
+
return { kty: 'EC', crv: 'P-256', x: base64url(pub.slice(1, 33)), y: base64url(pub.slice(33, 65)), d: base64url(secret) };
|
|
59
|
+
}
|
|
60
|
+
/** `key` checked to be a P-256 private JWK whose public half matches its secret (a JWK from storage or
|
|
61
|
+
* from the platform's `adoptHeldSession`). */
|
|
62
|
+
export function dpopKeyFromJwk(key) {
|
|
63
|
+
const k = key;
|
|
64
|
+
if (!k || k.kty !== 'EC' || k.crv !== 'P-256' || typeof k.d !== 'string' || typeof k.x !== 'string' || typeof k.y !== 'string') {
|
|
65
|
+
throw new Error('techne-sdk/session: the DPoP key is not a P-256 private JWK');
|
|
66
|
+
}
|
|
67
|
+
const derived = jwkOf(fromBase64url(k.d));
|
|
68
|
+
if (derived.x !== k.x || derived.y !== k.y)
|
|
69
|
+
throw new Error('techne-sdk/session: the DPoP key does not match its public half');
|
|
70
|
+
return derived;
|
|
71
|
+
}
|
|
72
|
+
/** The public half of `key`. */
|
|
73
|
+
export function publicJwk(key) {
|
|
74
|
+
return { kty: key.kty, crv: key.crv, x: key.x, y: key.y };
|
|
75
|
+
}
|
|
76
|
+
/** The RFC 7638 thumbprint of `key` (`jkt`): base64url SHA-256 of its required members in order. */
|
|
77
|
+
export function jwkThumbprint(key) {
|
|
78
|
+
return sha256b64url(JSON.stringify({ crv: key.crv, kty: key.kty, x: key.x, y: key.y }));
|
|
79
|
+
}
|
|
80
|
+
/** A random URL-safe string from `n` random bytes (`jti`, the PKCE verifier). */
|
|
81
|
+
export function randomString(n = 32) {
|
|
82
|
+
return base64url(randomBytes(n));
|
|
83
|
+
}
|
|
84
|
+
/** A PKCE pair (S256): the verifier the app keeps, the challenge it sends. */
|
|
85
|
+
export function pkcePair() {
|
|
86
|
+
const verifier = randomString(32);
|
|
87
|
+
return { verifier, challenge: sha256b64url(verifier) };
|
|
88
|
+
}
|
|
89
|
+
/** `url` without its query and fragment: a proof's `htu` (RFC 9449 section 4.2). */
|
|
90
|
+
export function htuOf(url) {
|
|
91
|
+
return url.replace(/[?#].*$/, '');
|
|
92
|
+
}
|
|
93
|
+
/** A DPoP proof (a `dpop+jwt`, ES256) by `key` for one request. Each has a fresh `jti`. */
|
|
94
|
+
export function dpopProof(key, p) {
|
|
95
|
+
const header = { typ: 'dpop+jwt', alg: 'ES256', jwk: publicJwk(key) };
|
|
96
|
+
const claims = { jti: randomString(16), htm: p.htm.toUpperCase(), htu: htuOf(p.htu), iat: p.iat ?? Math.floor(Date.now() / 1000) };
|
|
97
|
+
if (p.nonce)
|
|
98
|
+
claims.nonce = p.nonce;
|
|
99
|
+
if (p.token !== undefined)
|
|
100
|
+
claims.ath = sha256b64url(p.token);
|
|
101
|
+
const input = `${base64url(utf8(JSON.stringify(header)))}.${base64url(utf8(JSON.stringify(claims)))}`;
|
|
102
|
+
// noble hashes the message with SHA-256 first (prehash) and answers the 64-byte r||s JWS wants.
|
|
103
|
+
const sig = p256.sign(utf8(input), fromBase64url(key.d));
|
|
104
|
+
return `${input}.${base64url(sig)}`;
|
|
105
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/session — a session the app holds itself, for React Native (Hermes) as well as the browser:
|
|
3
|
+
* sign-in through the platform's phone door in own-session mode, the tokens and their DPoP key on the
|
|
4
|
+
* device, refresh and revoke through the platform's relay, and the narrow device credential with a proof
|
|
5
|
+
* per request. Plain JavaScript (`@noble/curves` P-256), no native module. The host provides
|
|
6
|
+
* `crypto.getRandomValues` (React Native: `react-native-get-random-values`) and `TextEncoder` (Hermes has it
|
|
7
|
+
* from React Native 0.74).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { OwnSession, startPhoneSignIn, finishPhoneSignIn } from 'techne-sdk/session'
|
|
11
|
+
* import { connect } from 'techne-sdk/connect'
|
|
12
|
+
*
|
|
13
|
+
* const pending = await startPhoneSignIn({ platformUrl, phone })
|
|
14
|
+
* const { session: data } = await finishPhoneSignIn(pending, code, { platformUrl, device: { platform: 'ios' } })
|
|
15
|
+
* const session = await OwnSession.signedIn(data, { platformUrl, store }) // later: OwnSession.restore({ platformUrl, store })
|
|
16
|
+
* const techne = connect(session, TECHNE_PLATFORM_DID)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { dpopProof, generateDpopKey, jwkThumbprint, type DpopKey, type ProofFor } from './dpop.js';
|
|
20
|
+
export { OwnSession, deviceProofHeaders, type OwnSessionData, type OwnSessionOptions, type RefreshLock, type TokenStore } from './own-session.js';
|
|
21
|
+
export { adoptHeldSession, finishPhoneSignIn, startPhoneSignIn, type FinishPhoneSignInOptions, type OwnSessionEndpoints, type PendingPhoneSignIn, type PhoneSignInOptions, } from './phone.js';
|
|
22
|
+
export { NETWORK_ERROR, OwnSessionError, SESSION_ENDED } from './relay.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/session — a session the app holds itself, for React Native (Hermes) as well as the browser:
|
|
3
|
+
* sign-in through the platform's phone door in own-session mode, the tokens and their DPoP key on the
|
|
4
|
+
* device, refresh and revoke through the platform's relay, and the narrow device credential with a proof
|
|
5
|
+
* per request. Plain JavaScript (`@noble/curves` P-256), no native module. The host provides
|
|
6
|
+
* `crypto.getRandomValues` (React Native: `react-native-get-random-values`) and `TextEncoder` (Hermes has it
|
|
7
|
+
* from React Native 0.74).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { OwnSession, startPhoneSignIn, finishPhoneSignIn } from 'techne-sdk/session'
|
|
11
|
+
* import { connect } from 'techne-sdk/connect'
|
|
12
|
+
*
|
|
13
|
+
* const pending = await startPhoneSignIn({ platformUrl, phone })
|
|
14
|
+
* const { session: data } = await finishPhoneSignIn(pending, code, { platformUrl, device: { platform: 'ios' } })
|
|
15
|
+
* const session = await OwnSession.signedIn(data, { platformUrl, store }) // later: OwnSession.restore({ platformUrl, store })
|
|
16
|
+
* const techne = connect(session, TECHNE_PLATFORM_DID)
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { dpopProof, generateDpopKey, jwkThumbprint } from './dpop.js';
|
|
20
|
+
export { OwnSession, deviceProofHeaders } from './own-session.js';
|
|
21
|
+
export { adoptHeldSession, finishPhoneSignIn, startPhoneSignIn, } from './phone.js';
|
|
22
|
+
export { NETWORK_ERROR, OwnSessionError, SESSION_ENDED } from './relay.js';
|