kitty-agent 9.1.0 → 9.2.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/out/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './cid.js';
3
3
  export * from './rkey.js';
4
4
  export * from './pds-helpers.js';
5
5
  export * from './shortid.js';
6
+ export * from './shortid2.js';
6
7
  export * from './sample-authenticated-client.js';
7
8
  export { resolveHandleAnonymously } from './handles/resolve.js';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
package/out/index.js CHANGED
@@ -3,6 +3,7 @@ export * from './cid.js';
3
3
  export * from './rkey.js';
4
4
  export * from './pds-helpers.js';
5
5
  export * from './shortid.js';
6
+ export * from './shortid2.js';
6
7
  export * from './sample-authenticated-client.js';
7
8
  export { resolveHandleAnonymously } from './handles/resolve.js';
8
9
  //# sourceMappingURL=index.js.map
package/out/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,178 @@
1
+ import type { Did } from "@atcute/lexicons";
2
+ import type { KittyAgent } from "./agent.js";
3
+ import { BaseStatefulOAuthClient, type Account, type LoginState } from "./oauth-stateful-base.js";
4
+ declare namespace PreactSignals {
5
+ const BRAND_SYMBOL: unique symbol;
6
+ type Node = {
7
+ _source: Signal;
8
+ _prevSource?: Node;
9
+ _nextSource?: Node;
10
+ _target: Computed | Effect;
11
+ _prevTarget?: Node;
12
+ _nextTarget?: Node;
13
+ _version: number;
14
+ _rollbackNode?: Node;
15
+ };
16
+ /**
17
+ * Combine multiple value updates into one "commit" at the end of the provided callback.
18
+ *
19
+ * Batches can be nested and changes are only flushed once the outermost batch callback
20
+ * completes.
21
+ *
22
+ * Accessing a signal that has been modified within a batch will reflect its updated
23
+ * value.
24
+ *
25
+ * @param fn The callback function.
26
+ * @returns The value returned by the callback.
27
+ */
28
+ function batch<T>(fn: () => T): T;
29
+ /**
30
+ * Run a callback function that can access signal values without
31
+ * subscribing to the signal updates.
32
+ *
33
+ * @param fn The callback function.
34
+ * @returns The value returned by the callback.
35
+ */
36
+ function untracked<T>(fn: () => T): T;
37
+ /**
38
+ * The base class for plain and computed signals.
39
+ */
40
+ class Signal<T = any> {
41
+ constructor(value?: T, options?: SignalOptions<T>);
42
+ subscribe(fn: (value: T) => void): () => void;
43
+ name?: string;
44
+ valueOf(): T;
45
+ toString(): string;
46
+ toJSON(): T;
47
+ peek(): T;
48
+ brand: typeof BRAND_SYMBOL;
49
+ get value(): T;
50
+ set value(value: T);
51
+ }
52
+ interface SignalOptions<T = any> {
53
+ watched?: (this: Signal<T>) => void;
54
+ unwatched?: (this: Signal<T>) => void;
55
+ name?: string;
56
+ }
57
+ /**
58
+ * Create a new plain signal.
59
+ *
60
+ * @param value The initial value for the signal.
61
+ * @returns A new signal.
62
+ */
63
+ function signal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
64
+ function signal<T = undefined>(): Signal<T | undefined>;
65
+ /**
66
+ * The base class for computed signals.
67
+ */
68
+ class Computed<T = any> extends Signal<T> {
69
+ _fn: () => T;
70
+ _sources?: Node;
71
+ _globalVersion: number;
72
+ _flags: number;
73
+ constructor(fn: () => T, options?: SignalOptions<T>);
74
+ _notify(): void;
75
+ get value(): T;
76
+ }
77
+ /**
78
+ * An interface for read-only signals.
79
+ */
80
+ interface ReadonlySignal<T = any> {
81
+ readonly value: T;
82
+ peek(): T;
83
+ subscribe(fn: (value: T) => void): () => void;
84
+ valueOf(): T;
85
+ toString(): string;
86
+ toJSON(): T;
87
+ brand: typeof BRAND_SYMBOL;
88
+ }
89
+ /**
90
+ * Create a new signal that is computed based on the values of other signals.
91
+ *
92
+ * The returned computed signal is read-only, and its value is automatically
93
+ * updated when any signals accessed from within the callback function change.
94
+ *
95
+ * @param fn The effect callback.
96
+ * @returns A new read-only signal.
97
+ */
98
+ function computed<T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>;
99
+ type EffectFn = ((this: {
100
+ dispose: () => void;
101
+ }) => void | (() => void)) | (() => void | (() => void));
102
+ /**
103
+ * The base class for reactive effects.
104
+ */
105
+ class Effect {
106
+ _fn?: EffectFn;
107
+ _cleanup?: () => void;
108
+ _sources?: Node;
109
+ _nextBatchedEffect?: Effect;
110
+ _flags: number;
111
+ _debugCallback?: () => void;
112
+ name?: string;
113
+ constructor(fn: EffectFn, options?: EffectOptions);
114
+ _callback(): void;
115
+ _start(): () => void;
116
+ _notify(): void;
117
+ _dispose(): void;
118
+ dispose(): void;
119
+ }
120
+ interface EffectOptions {
121
+ name?: string;
122
+ }
123
+ /**
124
+ * Create an effect to run arbitrary code in response to signal changes.
125
+ *
126
+ * An effect tracks which signals are accessed within the given callback
127
+ * function `fn`, and re-runs the callback when those signals change.
128
+ *
129
+ * The callback may return a cleanup function. The cleanup function gets
130
+ * run once, either when the callback is next called or when the effect
131
+ * gets disposed, whichever happens first.
132
+ *
133
+ * @param fn The effect callback.
134
+ * @returns A function for disposing the effect.
135
+ */
136
+ function effect(fn: EffectFn, options?: EffectOptions): () => void;
137
+ function action<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
138
+ /** Models should only contain signals, actions, and nested objects containing only signals and actions. */
139
+ type ValidateModel<TModel> = {
140
+ [Key in keyof TModel]: TModel[Key] extends ReadonlySignal<unknown> ? TModel[Key] : TModel[Key] extends (...args: any[]) => any ? TModel[Key] : TModel[Key] extends object ? ValidateModel<TModel[Key]> : `Property ${Key extends string ? `'${Key}' ` : ""}is not a Signal, Action, or an object that contains only Signals and Actions.`;
141
+ };
142
+ type Model<TModel> = ValidateModel<TModel> & Disposable;
143
+ type ModelFactory<TModel, TFactoryArgs extends any[] = []> = (...args: TFactoryArgs) => ValidateModel<TModel>;
144
+ type ModelConstructor<TModel, TFactoryArgs extends any[] = []> = new (...args: TFactoryArgs) => Model<TModel>;
145
+ function createModel<TModel, TFactoryArgs extends any[] = []>(modelFactory: ModelFactory<TModel, TFactoryArgs>): ModelConstructor<TModel, TFactoryArgs>;
146
+ }
147
+ export declare class StatefulPreactOAuthClient<TClient> extends BaseStatefulOAuthClient<TClient> {
148
+ private _account;
149
+ private _agent;
150
+ private _client;
151
+ get account(): PreactSignals.ReadonlySignal<Account | undefined>;
152
+ readonly user: PreactSignals.ReadonlySignal<LoginState<TClient> | undefined>;
153
+ readonly handle: PreactSignals.ReadonlySignal<string | undefined>;
154
+ readonly did: PreactSignals.ReadonlySignal<Did | undefined>;
155
+ readonly pds: PreactSignals.ReadonlySignal<string | undefined>;
156
+ protected get internal_account(): Account | undefined;
157
+ protected get internal_user(): LoginState<TClient> | undefined;
158
+ protected get internal_agent(): KittyAgent | undefined;
159
+ protected get internal_client(): TClient | undefined;
160
+ protected set internal_account(value: Account | undefined);
161
+ protected set internal_agent(value: KittyAgent | undefined);
162
+ protected set internal_client(value: TClient | undefined);
163
+ constructor(options: {
164
+ clientId: string;
165
+ redirectUri: string;
166
+ scope: string;
167
+ }, preact: {
168
+ signal: typeof PreactSignals.signal;
169
+ computed: typeof PreactSignals.computed;
170
+ }, createClient: (loginState: {
171
+ readonly handle: string;
172
+ readonly did: Did;
173
+ readonly pds: string;
174
+ readonly agent: KittyAgent;
175
+ }) => TClient);
176
+ }
177
+ export {};
178
+ //# sourceMappingURL=oauth-preact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-preact.d.ts","sourceRoot":"","sources":["../src/oauth-preact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAkB,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGlH,kBAAU,aAAa,CAAC;IACL,MAAM,YAAY,EAAE,OAAO,MAAM,CAAC;IACjD,KAAY,IAAI,GAAG;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,IAAI,CAAC;QACnB,WAAW,CAAC,EAAE,IAAI,CAAC;QACnB,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC;QAC3B,WAA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,SAAS,CAAgC;IACrF,SAAS,KAAK,aAAa,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,CAA4B;IAC1F,SAAS,KAAK,cAAc,IAAI,UAAU,GAAG,SAAS,CAA8B;IACpF,SAAS,KAAK,eAAe,IAAI,OAAO,GAAG,SAAS,CAA+B;IACnF,SAAS,KAAK,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAkC;IAC3F,SAAS,KAAK,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAgC;IAC1F,SAAS,KAAK,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAiC;gBAGrF,OAAO,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;KACjB,EACD,MAAM,EAAE;QACJ,MAAM,EAAE,OAAO,aAAa,CAAC,MAAM,CAAC;QACpC,QAAQ,EAAE,OAAO,aAAa,CAAC,QAAQ,CAAC;KAC3C,EACD,YAAY,EAAE,CAAC,UAAU,EAAE;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;QAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;KAC9B,KAAK,OAAO;CA2CpB"}
@@ -0,0 +1,58 @@
1
+ import { BaseStatefulOAuthClient, LoginStateImpl } from "./oauth-stateful-base.js";
2
+ var PreactSignals;
3
+ (function (PreactSignals) {
4
+ })(PreactSignals || (PreactSignals = {}));
5
+ export class StatefulPreactOAuthClient extends BaseStatefulOAuthClient {
6
+ _account;
7
+ _agent;
8
+ _client;
9
+ get account() { return this._account; }
10
+ user;
11
+ handle;
12
+ did;
13
+ pds;
14
+ get internal_account() { return this._account.value; }
15
+ get internal_user() { return this.user.value; }
16
+ get internal_agent() { return this._agent.value; }
17
+ get internal_client() { return this._client.value; }
18
+ set internal_account(value) { this._account.value = value; }
19
+ set internal_agent(value) { this._agent.value = value; }
20
+ set internal_client(value) { this._client.value = value; }
21
+ constructor(options, preact, createClient) {
22
+ super(options, createClient);
23
+ function useLocalStorage(key, initialValue, options) {
24
+ const value = preact.signal(initialValue, { name: `localStorage:${key}` });
25
+ if (key in localStorage) {
26
+ value.value = options.deserializer(localStorage[key]);
27
+ }
28
+ value.subscribe(newValue => {
29
+ localStorage[key] = options.serializer(newValue);
30
+ });
31
+ return value;
32
+ }
33
+ this._account = useLocalStorage('user', undefined, {
34
+ deserializer(raw) { return raw === 'null' ? undefined : JSON.parse(raw); },
35
+ serializer(value) { return value === undefined ? 'null' : JSON.stringify(value); },
36
+ });
37
+ this._agent = preact.signal(undefined, { name: 'agent' });
38
+ this._client = preact.signal(undefined, { name: 'client' });
39
+ this.user = preact.computed(() => {
40
+ const account = this._account.value;
41
+ const agent = this._agent.value;
42
+ const client = this._client.value;
43
+ return account && agent && client ? new LoginStateImpl(account, agent, client) : undefined;
44
+ }, {
45
+ name: 'user',
46
+ });
47
+ this.handle = preact.computed(() => this._account.value?.handle, {
48
+ name: 'handle',
49
+ });
50
+ this.did = preact.computed(() => this._account.value?.did, {
51
+ name: 'did',
52
+ });
53
+ this.pds = preact.computed(() => this._account.value?.pds, {
54
+ name: 'pds',
55
+ });
56
+ }
57
+ }
58
+ //# sourceMappingURL=oauth-preact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-preact.js","sourceRoot":"","sources":["../src/oauth-preact.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAiC,MAAM,0BAA0B,CAAC;AAGlH,IAAU,aAAa,CA8ItB;AA9ID,WAAU,aAAa;AA8IvB,CAAC,EA9IS,aAAa,KAAb,aAAa,QA8ItB;AAED,MAAM,OAAO,yBAAmC,SAAQ,uBAAgC;IAC5E,QAAQ,CAA4C;IACpD,MAAM,CAA+C;IACrD,OAA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AG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE;YAC7D,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;YACvD,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;YACvD,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1,36 @@
1
+ declare const EPOCH = 1771196391050;
2
+ type ShortIdString<Epoch extends number = typeof EPOCH> = string & {
3
+ __epoch: Epoch;
4
+ };
5
+ /**
6
+ * Short rkey-compatible ID composed of 53-bit millisecond-precise monotonically increasing timestamp
7
+ * (customizable epoch) and 10-bit random clock ID, serialized into a 67-character, ATProto record key
8
+ * compatible alphabet.
9
+ *
10
+ * Format: clock_id (10-bit integer encoded to s67, padded to length 2 with 'A') || timestamp_millis (53-bit
11
+ * integer encoded to s67, variable length)
12
+ */
13
+ export declare class ShortId2 {
14
+ /**
15
+ * Creates a ShortID based off provided timestamp and clockid, with no validation.
16
+ */
17
+ static createRaw(timestamp: number, clockid: number): string;
18
+ /**
19
+ * Creates a ShortID based off provided timestamp and clockid
20
+ */
21
+ static create(timestamp: number, clockid: number): string;
22
+ /**
23
+ * Return a ShortID based on current time
24
+ */
25
+ static now<Epoch extends number>(epoch: Epoch): ShortIdString<Epoch>;
26
+ static now(): ShortIdString<typeof EPOCH>;
27
+ /**
28
+ * Get the Date corresponding to the timestamp encoded in a ShortId, using the provided epoch (or default EPOCH)
29
+ * @param shortId The ShortId
30
+ * @param epoch The epoch to use for decoding the timestamp, defaults to EPOCH
31
+ */
32
+ static getDate<Epoch extends number = typeof EPOCH>(shortId: ShortIdString<Epoch>, epoch: Epoch): Date;
33
+ static getDate(shortId: ShortIdString<typeof EPOCH>): Date;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=shortid2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortid2.d.ts","sourceRoot":"","sources":["../src/shortid2.ts"],"names":[],"mappings":"AAyBA,QAAA,MAAM,KAAK,gBAAgB,CAAC;AAE5B,KAAK,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,IAAI,MAAM,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAEtF;;;;;;;GAOG;AAEH,qBAAa,QAAQ;IACjB;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAI5D;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAYzD;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,aAAa,CAAC,OAAO,KAAK,CAAC;IAQzC;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,SAAS,MAAM,GAAG,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IACtG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,KAAK,CAAC,GAAG,IAAI;CAM7D"}
@@ -0,0 +1,60 @@
1
+ const S67_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_:~';
2
+ function s67encode(i) {
3
+ let s = '';
4
+ while (i) {
5
+ const c = i % S67_CHAR.length;
6
+ i = Math.floor(i / S67_CHAR.length);
7
+ s = S67_CHAR.charAt(c) + s;
8
+ }
9
+ return s;
10
+ }
11
+ function s67decode(s) {
12
+ let i = 0;
13
+ for (let j = 0; j < s.length; j++) {
14
+ i = i * S67_CHAR.length + S67_CHAR.indexOf(s[j]);
15
+ }
16
+ return i;
17
+ }
18
+ let lastTimestamp = 0;
19
+ const EPOCH = 1771196391050; // Sun, Feb 15 2026 22:59:48 GMT, in Unix milliseconds
20
+ /**
21
+ * Short rkey-compatible ID composed of 53-bit millisecond-precise monotonically increasing timestamp
22
+ * (customizable epoch) and 10-bit random clock ID, serialized into a 67-character, ATProto record key
23
+ * compatible alphabet.
24
+ *
25
+ * Format: clock_id (10-bit integer encoded to s67, padded to length 2 with 'A') || timestamp_millis (53-bit
26
+ * integer encoded to s67, variable length)
27
+ */
28
+ // biome-ignore lint/complexity/noStaticOnlyClass: By design
29
+ export class ShortId2 {
30
+ /**
31
+ * Creates a ShortID based off provided timestamp and clockid, with no validation.
32
+ */
33
+ static createRaw(timestamp, clockid) {
34
+ return `${s67encode(clockid).padStart(2, S67_CHAR[0])}${s67encode(timestamp)}`;
35
+ }
36
+ /**
37
+ * Creates a ShortID based off provided timestamp and clockid
38
+ */
39
+ static create(timestamp, clockid) {
40
+ if (timestamp < 0 || !Number.isSafeInteger(timestamp)) {
41
+ throw new Error('invalid timestamp');
42
+ }
43
+ if (clockid < 0 || clockid > 1023) {
44
+ throw new Error('invalid clockid');
45
+ }
46
+ return ShortId2.createRaw(timestamp, clockid);
47
+ }
48
+ static now(epoch = EPOCH) {
49
+ const timestamp = Math.max(Date.now() - epoch, lastTimestamp);
50
+ lastTimestamp = timestamp + 1;
51
+ return ShortId2.createRaw(timestamp, Math.floor(Math.random() * 1023));
52
+ }
53
+ ;
54
+ static getDate(shortId, epoch = EPOCH) {
55
+ const timestampPart = shortId.slice(2);
56
+ const timestamp = s67decode(timestampPart);
57
+ return new Date(timest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CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,SAAiB,EAAE,OAAe;QAC5C,IAAI,SAAS,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,IAAI,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAOD,MAAM,CAAC,GAAG,CAAsC,QAAe,KAAc;QACzE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,aAAa,CAAC,CAAC;QAC9D,aAAa,GAAG,SAAS,GAAG,CAAC,CAAC;QAE9B,OAAO,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAyB,CAAC;IACnG,CAAC;IAAA,CAAC;IASF,MAAM,CAAC,OAAO,CAAsC,OAA6B,EAAE,QAAe,KAAc;QAC5G,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC;QAC3C,OAAO,IAAI,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;IACvC,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kitty-agent",
3
3
  "type": "module",
4
- "version": "9.1.0",
4
+ "version": "9.2.0",
5
5
  "description": "Helpers for @atcute/client",
6
6
  "main": "out/index.js",
7
7
  "types": "out/index.d.ts",
@@ -47,6 +47,6 @@
47
47
  "@atcute/lexicons": "^1.2.9"
48
48
  },
49
49
  "scripts": {
50
- "build": "tsc"
50
+ "build": "pnpm --package=typescript dlx tsc"
51
51
  }
52
52
  }