@fastxyz/fastid-sdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/reader.d.ts +24 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +35 -0
- package/dist/reader.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,9 +7,18 @@ unchanged. The package is licensed under Apache-2.0, as specified in this
|
|
|
7
7
|
directory's LICENSE, independently of the monorepo's root license.
|
|
8
8
|
Copyright (c) Pi Squared, Inc.
|
|
9
9
|
|
|
10
|
-
## Install
|
|
10
|
+
## Install
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
The [public package](https://www.npmjs.com/package/@fastxyz/fastid-sdk) is
|
|
13
|
+
available on npm. Pin a version in an agent project:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @fastxyz/fastid-sdk@0.2.0
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
It builds and runs without access to the private Fast ID repository. The
|
|
20
|
+
following source-tarball path is only for testing an unpublished change from a
|
|
21
|
+
public `fast-sdk` checkout:
|
|
13
22
|
|
|
14
23
|
```sh
|
|
15
24
|
corepack pnpm install --frozen-lockfile
|
|
@@ -19,9 +28,6 @@ corepack pnpm --filter @fastxyz/fastid-sdk pack --pack-destination /tmp/fastid-s
|
|
|
19
28
|
npm install /tmp/fastid-sdk-pack/fastxyz-fastid-sdk-*.tgz
|
|
20
29
|
```
|
|
21
30
|
|
|
22
|
-
After npm publication, the package name is `@fastxyz/fastid-sdk`. Building and
|
|
23
|
-
using it requires no access to the private Fast ID repository.
|
|
24
|
-
|
|
25
31
|
```ts
|
|
26
32
|
import { IdClient, KeySigner } from '@fastxyz/fastid-sdk';
|
|
27
33
|
|
|
@@ -30,6 +36,19 @@ const client = new IdClient({ network: 'fast:testnet', signer });
|
|
|
30
36
|
const availability = await client.availability('agent.sdk');
|
|
31
37
|
```
|
|
32
38
|
|
|
39
|
+
For lookups only (for example, turning `alice.smith` into the `fast1...` address
|
|
40
|
+
to pay), use `IdReader`, which needs no signer and applies the same response
|
|
41
|
+
checks (network and name binding) as `IdClient`:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { IdReader, isCanonicalName } from '@fastxyz/fastid-sdk';
|
|
45
|
+
|
|
46
|
+
const reader = new IdReader({ network: 'fast:mainnet' });
|
|
47
|
+
if (isCanonicalName('alice.smith')) {
|
|
48
|
+
const { address } = await reader.resolve('alice.smith'); // fast1...
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
33
52
|
The client supports public identity reads, name/website/GitHub/ORCID/X claims,
|
|
34
53
|
DOI imports, profile updates, revocation, sealed reports and sharing URLs. Use
|
|
35
54
|
`fast:mainnet` when intending to use production. Paid operations use the supplied
|
|
@@ -50,6 +69,154 @@ known provider identity; the SDK polls the persisted proof, without receiving
|
|
|
50
69
|
OAuth callbacks or tokens. See the served [agent guide](https://id.fast.xyz/AGENTS.md)
|
|
51
70
|
for the full capability and recovery contracts.
|
|
52
71
|
|
|
72
|
+
## Claim a name and read it back (testnet)
|
|
73
|
+
|
|
74
|
+
This example **submits a Fast transaction that may carry a network fee**. Use
|
|
75
|
+
only a testnet key whose owner has authorized the particular claim and any
|
|
76
|
+
applicable fee, and fund that address when a fee applies. Never put a private
|
|
77
|
+
key in the source file or print it. A production integration can supply its own
|
|
78
|
+
authorized `Signer` instead of loading a key from the environment.
|
|
79
|
+
|
|
80
|
+
1. Check the current network fee before authorizing the operation:
|
|
81
|
+
|
|
82
|
+
| Network | Public `GET /v1/network-info` |
|
|
83
|
+
|---|---|
|
|
84
|
+
| Testnet | https://testnet.api.fast.xyz/proxy-rest/v1/network-info |
|
|
85
|
+
| Mainnet | https://api.fast.xyz/proxy-rest/v1/network-info |
|
|
86
|
+
|
|
87
|
+
Confirm `data.network_id`, then find the entry in `data.fees.entries` whose
|
|
88
|
+
`token_id` equals `data.fees.default`. Its `fixed_amount` is a decimal string
|
|
89
|
+
in **atomic units**, not a display amount. For a nonzero fee, fetch the token
|
|
90
|
+
metadata and decimals from `GET /v1/tokens?token_ids=<default>` on the same
|
|
91
|
+
`proxy-rest` origin. An empty authoritative fee list or a zero default fee
|
|
92
|
+
means no fee; a failed or malformed request does **not** mean no fee. The SDK
|
|
93
|
+
resolves the authoritative schedule during the claim and refuses unavailable
|
|
94
|
+
or ambiguous fee data. This preview does not pin the schedule or enforce a
|
|
95
|
+
spending ceiling if the network changes it before submission.
|
|
96
|
+
|
|
97
|
+
2. Provide `FAST_ID_NAME`, a privately held `FAST_ID_PRIVATE_KEY` (a bare
|
|
98
|
+
64-character hex Ed25519 key), and `FAST_ID_JOURNAL` (a new, private file on
|
|
99
|
+
persistent storage) to a Node 20.19+ process. Save the following as
|
|
100
|
+
`claim.mjs` and run `node claim.mjs` **once for this authorization**. The
|
|
101
|
+
journal file must not already exist; do not use a newly generated, unfunded
|
|
102
|
+
key for a paid claim or rerun this script to retry a late read-back.
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import { constants, closeSync, fsyncSync, openSync, writeFileSync } from 'node:fs';
|
|
106
|
+
import { dirname } from 'node:path';
|
|
107
|
+
import {
|
|
108
|
+
IdClient,
|
|
109
|
+
IndeterminateSubmissionError,
|
|
110
|
+
KeySigner,
|
|
111
|
+
RegistrationPendingError,
|
|
112
|
+
} from '@fastxyz/fastid-sdk';
|
|
113
|
+
|
|
114
|
+
const name = process.env.FAST_ID_NAME;
|
|
115
|
+
const privateKey = process.env.FAST_ID_PRIVATE_KEY;
|
|
116
|
+
const journalPath = process.env.FAST_ID_JOURNAL;
|
|
117
|
+
if (!name || !privateKey || !journalPath) {
|
|
118
|
+
throw new Error('Missing name, authorized key, or journal path');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const signer = await KeySigner.fromPrivateKey(privateKey);
|
|
122
|
+
const client = new IdClient({ network: 'fast:testnet', signer });
|
|
123
|
+
|
|
124
|
+
// Advisory read. claimName performs its own fresh, fail-closed preflight.
|
|
125
|
+
const availability = await client.availability(name);
|
|
126
|
+
if (!availability.available) throw new Error('Name is not available');
|
|
127
|
+
|
|
128
|
+
// An existing journal stops this script before it can submit another claim.
|
|
129
|
+
const journal = openSync(
|
|
130
|
+
journalPath,
|
|
131
|
+
constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_APPEND,
|
|
132
|
+
0o600,
|
|
133
|
+
);
|
|
134
|
+
const save = (event) => {
|
|
135
|
+
writeFileSync(journal, `${JSON.stringify(event)}\n`);
|
|
136
|
+
fsyncSync(journal);
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
save({ stage: 'attempting', network: 'fast:testnet', address: signer.address, name });
|
|
140
|
+
// Persist the new directory entry before the paid request. Any failure aborts.
|
|
141
|
+
const journalDirectory = openSync(dirname(journalPath), constants.O_RDONLY);
|
|
142
|
+
try {
|
|
143
|
+
fsyncSync(journalDirectory);
|
|
144
|
+
} finally {
|
|
145
|
+
closeSync(journalDirectory);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
let claim;
|
|
149
|
+
try {
|
|
150
|
+
claim = await client.claimName(name); // Signs and submits one claim.
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (error instanceof RegistrationPendingError) {
|
|
153
|
+
save({ stage: 'registration_pending', pending: error.pending });
|
|
154
|
+
} else if (error instanceof IndeterminateSubmissionError) {
|
|
155
|
+
save({
|
|
156
|
+
stage: 'indeterminate',
|
|
157
|
+
network: error.network,
|
|
158
|
+
address: error.address,
|
|
159
|
+
nonce: error.nonce?.toString(),
|
|
160
|
+
txIdHex: error.txIdHex,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
save({
|
|
166
|
+
stage: 'registered',
|
|
167
|
+
network: 'fast:testnet',
|
|
168
|
+
address: signer.address,
|
|
169
|
+
name,
|
|
170
|
+
nonce: claim.nonce,
|
|
171
|
+
txIdHex: claim.txIdHex,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// These reads can fail without losing the already saved claim transaction ID.
|
|
175
|
+
const identity = await client.identity(signer.address);
|
|
176
|
+
const record = await client.resolve(name);
|
|
177
|
+
if (
|
|
178
|
+
identity.name !== name ||
|
|
179
|
+
identity.name_claim_tx !== claim.txIdHex ||
|
|
180
|
+
record.name !== name ||
|
|
181
|
+
record.address !== signer.address ||
|
|
182
|
+
record.name_claim_tx !== claim.txIdHex
|
|
183
|
+
) {
|
|
184
|
+
throw new Error('Claim not yet visible in reads; retry reads, not payment');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
console.log({
|
|
188
|
+
txIdHex: claim.txIdHex,
|
|
189
|
+
profileUrl: client.share.profileUrl(name),
|
|
190
|
+
});
|
|
191
|
+
} finally {
|
|
192
|
+
closeSync(journal);
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If `claimName()` throws `RegistrationTerminalError`, settlement has completed
|
|
197
|
+
and the error reports `feeSpent === true` (the network fee may have been
|
|
198
|
+
charged). This example cannot persist a transaction ID from that error, so
|
|
199
|
+
the journal remains at `attempting`; its existing-file guard prevents
|
|
200
|
+
rerunning the script. Do not remove or replace
|
|
201
|
+
the journal or submit another claim. Manually reconcile using trusted
|
|
202
|
+
transaction evidence before any further payment.
|
|
203
|
+
|
|
204
|
+
3. This read-back confirms what the Fast ID index currently reports; it is not
|
|
205
|
+
an independent validator-quorum proof of on-chain settlement. If it is not
|
|
206
|
+
yet visible, repeat **only** `identity` and `resolve` with the `registered`
|
|
207
|
+
journal entry's name, address and transaction ID; never rerun `claim.mjs`
|
|
208
|
+
or call `claimName` merely because a read is late. For
|
|
209
|
+
`registration_pending`, pass the saved `pending` record to
|
|
210
|
+
`client.retryRegistration(...)`; this retries registration only. For
|
|
211
|
+
`indeterminate`, the journal retains available network, address, nonce and
|
|
212
|
+
transaction ID hints; reconcile before any further paid action. The SDK's
|
|
213
|
+
`recoveryEnvelope` is an in-memory structured clone, **not** a JSON-safe
|
|
214
|
+
persistence format, and these hints may be insufficient to reconcile on
|
|
215
|
+
their own. If a journal write fails after submission, stop and investigate;
|
|
216
|
+
never interpret that failure or a missing read as permission to pay again.
|
|
217
|
+
See the [testnet agent guide](https://testnet.id.fast.xyz/AGENTS.md) for the remaining
|
|
218
|
+
recovery and evidence limits.
|
|
219
|
+
|
|
53
220
|
## Development and web parity
|
|
54
221
|
|
|
55
222
|
```sh
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { CLAIM_DATA_KINDS, CLAIM_DATA_V2_MAX_BYTES, CLAIM_DATA_V2_SCHEMA, claimDataHex, encodeClaimDataV2, isCanonicalClaimValue, isClaimDataKind, type ClaimDataKind, } from "./claim-data.js";
|
|
2
2
|
export { type PendingRegistration, type RegisteredClaim, type RevocableClaimKind, } from "./claims.js";
|
|
3
3
|
export { IdClient, type IdClientOptions } from "./client.js";
|
|
4
|
+
export { IdReader, type IdReaderOptions } from "./reader.js";
|
|
5
|
+
export { isCanonicalName } from "./name.js";
|
|
4
6
|
export * from "./errors.js";
|
|
5
7
|
export { HttpError } from "./http.js";
|
|
6
8
|
export { type IdNetwork } from "./networks.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { CLAIM_DATA_KINDS, CLAIM_DATA_V2_MAX_BYTES, CLAIM_DATA_V2_SCHEMA, claimDataHex, encodeClaimDataV2, isCanonicalClaimValue, isClaimDataKind, } from "./claim-data.js";
|
|
2
2
|
export { IdClient } from "./client.js";
|
|
3
|
+
export { IdReader } from "./reader.js";
|
|
4
|
+
export { isCanonicalName } from "./name.js";
|
|
3
5
|
export * from "./errors.js";
|
|
4
6
|
export { HttpError } from "./http.js";
|
|
5
7
|
export { REPORT_BODY_LIMIT, REPORT_CIPHERTEXT_LIMIT, REPORT_TEXT_MAX, } from "./report.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,QAAQ,EAAwB,MAAM,aAAa,CAAC;AAC7D,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA6BtC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,GAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,QAAQ,EAAwB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAwB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA6BtC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,GAIhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC"}
|
package/dist/reader.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type IdNetwork } from "./networks.js";
|
|
2
|
+
import { type Availability, type AvailabilityReadOptions, type IdentityDocument, type OwnerLinks, type PropertyClaimedResult, type PropertyClaimKind, type ResolvedId } from "./reads.js";
|
|
3
|
+
export interface IdReaderOptions {
|
|
4
|
+
network: IdNetwork;
|
|
5
|
+
fetchImpl?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Signer-free access to the public Fast ID reads.
|
|
9
|
+
*
|
|
10
|
+
* Use this when you only need to look identities up (for example, resolving
|
|
11
|
+
* `alice.smith` to its `fast1…` address before a transfer). It performs the
|
|
12
|
+
* same response validation as {@link IdClient}, including the network and
|
|
13
|
+
* name-binding checks, but needs no key material.
|
|
14
|
+
*/
|
|
15
|
+
export declare class IdReader {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(options: IdReaderOptions);
|
|
18
|
+
resolve(identity: string): Promise<ResolvedId>;
|
|
19
|
+
identity(address: string): Promise<IdentityDocument>;
|
|
20
|
+
availability(name: string, options?: AvailabilityReadOptions): Promise<Availability>;
|
|
21
|
+
links(address: string): Promise<OwnerLinks>;
|
|
22
|
+
propertyClaimed(kind: PropertyClaimKind, value: string): Promise<PropertyClaimedResult>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,qBAAa,QAAQ;;gBAGP,OAAO,EAAE,eAAe;IAMpC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIpD,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,YAAY,CAAC;IAIxB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3C,eAAe,CACb,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,qBAAqB,CAAC;CAGlC"}
|
package/dist/reader.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HttpClient } from "./http.js";
|
|
2
|
+
import { networkFor } from "./networks.js";
|
|
3
|
+
import { IdReads, } from "./reads.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signer-free access to the public Fast ID reads.
|
|
6
|
+
*
|
|
7
|
+
* Use this when you only need to look identities up (for example, resolving
|
|
8
|
+
* `alice.smith` to its `fast1…` address before a transfer). It performs the
|
|
9
|
+
* same response validation as {@link IdClient}, including the network and
|
|
10
|
+
* name-binding checks, but needs no key material.
|
|
11
|
+
*/
|
|
12
|
+
export class IdReader {
|
|
13
|
+
#reads;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const config = networkFor(options.network);
|
|
16
|
+
const http = new HttpClient(config.idOrigin, options.fetchImpl ?? fetch);
|
|
17
|
+
this.#reads = new IdReads(http, config.networkId);
|
|
18
|
+
}
|
|
19
|
+
resolve(identity) {
|
|
20
|
+
return this.#reads.resolve(identity);
|
|
21
|
+
}
|
|
22
|
+
identity(address) {
|
|
23
|
+
return this.#reads.identity(address);
|
|
24
|
+
}
|
|
25
|
+
availability(name, options) {
|
|
26
|
+
return this.#reads.availability(name, options);
|
|
27
|
+
}
|
|
28
|
+
links(address) {
|
|
29
|
+
return this.#reads.links(address);
|
|
30
|
+
}
|
|
31
|
+
propertyClaimed(kind, value) {
|
|
32
|
+
return this.#reads.propertyClaimed(kind, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,OAAO,GAQR,MAAM,YAAY,CAAC;AAOpB;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IACV,MAAM,CAAU;IAEzB,YAAY,OAAwB;QAClC,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,CAAC,QAAgB;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,QAAQ,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,YAAY,CACV,IAAY,EACZ,OAAiC;QAEjC,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,eAAe,CACb,IAAuB,EACvB,KAAa;QAEb,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastxyz/fastid-sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Programmatic client for id.fast.xyz — everything a non-admin user can do, for agents",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"effect": "^3.21.0",
|
|
36
36
|
"tr46": "6.0.0",
|
|
37
37
|
"@fastxyz/schema": "2.0.0",
|
|
38
|
-
"@fastxyz/sdk": "2.4.
|
|
38
|
+
"@fastxyz/sdk": "2.4.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^22",
|