@testerpaykit/api-client 2.0.0 → 3.1.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 +23 -0
- package/dist/index.d.mts +65 -31
- package/dist/index.d.ts +65 -31
- package/dist/index.js +67 -28
- package/dist/index.mjs +63 -27
- package/package.json +1 -1
- package/src/TesterPayKitApiClient.ts +106 -45
- package/tests/TesterPayKitApiClient.test.ts +59 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@testerpaykit/api-client` are documented here.
|
|
4
4
|
|
|
5
|
+
## 3.1.0 — 2026-11-14
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `clientHeader` in `ApiClientConfig`: sent as `X-TPK-Client` on every
|
|
9
|
+
request (e.g. `expo/2.2.0`). Default none.
|
|
10
|
+
- Version check: on a 426 `client_outdated` answer the client calls
|
|
11
|
+
`onClientOutdated(info)` once, `clientOutdated` holds the info, and every
|
|
12
|
+
later request rejects with `ClientOutdatedError` before it reaches the
|
|
13
|
+
network (no `response`, so retry queues keep their work).
|
|
14
|
+
`markClientOutdated(info)` blocks a client created later in the same run.
|
|
15
|
+
Also exported: `TPK_CLIENT_HEADER`, `parseClientOutdated`, the
|
|
16
|
+
`ClientOutdatedInfo` type.
|
|
17
|
+
|
|
18
|
+
## 3.0.0 — 2026-11-10
|
|
19
|
+
|
|
20
|
+
Breaking: `startPhoneVerification`, `confirmPhoneVerification` and their types
|
|
21
|
+
removed. Testers confirm their number once in the TPK app (decision
|
|
22
|
+
2026-11-10).
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- `createAppLink({ projectId, platform })` → `{ code, url, appUrl, expiresAt }`:
|
|
26
|
+
a short-lived code for confirming this install in the TPK app.
|
|
27
|
+
|
|
5
28
|
## 2.0.0 — 2026-11-07
|
|
6
29
|
|
|
7
30
|
Breaking: `submitSessionEndFeedback` removed.
|
package/dist/index.d.mts
CHANGED
|
@@ -162,7 +162,37 @@ interface ApiClientConfig {
|
|
|
162
162
|
baseURL?: string;
|
|
163
163
|
apiKey: string;
|
|
164
164
|
tokenManager?: TokenManager;
|
|
165
|
+
/**
|
|
166
|
+
* Sent as `X-TPK-Client` on every request, e.g. `expo/2.2.0` (decision
|
|
167
|
+
* 2026-11-14 "Mindestversion je Client-Art"). Default none: the server
|
|
168
|
+
* then serves the request without a version check.
|
|
169
|
+
*/
|
|
170
|
+
clientHeader?: string;
|
|
171
|
+
}
|
|
172
|
+
/** Request header a client identifies itself with (`<kind>/<version>`). */
|
|
173
|
+
declare const TPK_CLIENT_HEADER = "X-TPK-Client";
|
|
174
|
+
/** Body of a 426 `client_outdated` answer: this client is below the
|
|
175
|
+
* minimum version the server still serves. Fields are null when the
|
|
176
|
+
* request carried no `X-TPK-Client`. */
|
|
177
|
+
interface ClientOutdatedInfo {
|
|
178
|
+
kind: string | null;
|
|
179
|
+
min: string | null;
|
|
180
|
+
yours: string | null;
|
|
181
|
+
message: string | null;
|
|
165
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Thrown instead of sending, for every request after a 426
|
|
185
|
+
* `client_outdated` (see `TesterPayKitApiClient.clientOutdated`). It has
|
|
186
|
+
* no `response`, so callers that retry on network errors keep their
|
|
187
|
+
* queued work for a newer build instead of dropping it.
|
|
188
|
+
*/
|
|
189
|
+
declare class ClientOutdatedError extends Error {
|
|
190
|
+
readonly info: ClientOutdatedInfo;
|
|
191
|
+
readonly code = "TPK_CLIENT_OUTDATED";
|
|
192
|
+
constructor(info: ClientOutdatedInfo);
|
|
193
|
+
}
|
|
194
|
+
/** The `client_outdated` body of a 426 answer, else null. */
|
|
195
|
+
declare function parseClientOutdated(status: number | undefined, body: unknown): ClientOutdatedInfo | null;
|
|
166
196
|
/**
|
|
167
197
|
* TesterPayKit API Client implementation using Axios.
|
|
168
198
|
*
|
|
@@ -183,6 +213,20 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
183
213
|
* tester UI on it. The request still rejects as before.
|
|
184
214
|
*/
|
|
185
215
|
onTesterGate: ((reason: TesterGateReason) => void) | null;
|
|
216
|
+
/**
|
|
217
|
+
* Called once, on the first 426 `client_outdated` answer. From then on
|
|
218
|
+
* this client sends nothing: every request rejects with
|
|
219
|
+
* [ClientOutdatedError] before it reaches the network.
|
|
220
|
+
*/
|
|
221
|
+
onClientOutdated: ((info: ClientOutdatedInfo) => void) | null;
|
|
222
|
+
private outdated;
|
|
223
|
+
/** Set after a 426 `client_outdated`; null while the server serves us. */
|
|
224
|
+
get clientOutdated(): ClientOutdatedInfo | null;
|
|
225
|
+
/**
|
|
226
|
+
* Blocks this client as if it had received the 426 itself (an earlier
|
|
227
|
+
* client in the same app run did). Does not call [onClientOutdated].
|
|
228
|
+
*/
|
|
229
|
+
markClientOutdated(info: ClientOutdatedInfo): void;
|
|
186
230
|
constructor(config: ApiClientConfig);
|
|
187
231
|
/**
|
|
188
232
|
* Setup request/response interceptors for JWT authentication.
|
|
@@ -389,22 +433,16 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
389
433
|
*/
|
|
390
434
|
getMyProfile(): Promise<TesterProfile>;
|
|
391
435
|
/**
|
|
392
|
-
* POST /v1/testers/me/phone/
|
|
393
|
-
*
|
|
394
|
-
*
|
|
436
|
+
* POST /v1/testers/me/phone/link — a short-lived code for confirming this
|
|
437
|
+
* install in the TPK app (decision 2026-11-10, replaces the SMS dialog).
|
|
438
|
+
* Open `appUrl` (TPK app installed) or `url` (web page with an install
|
|
439
|
+
* hint); the person allows it there, then GET /v1/testers/me/profile
|
|
440
|
+
* reports the install as confirmed.
|
|
395
441
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* `device` binds the number to this physical device (migration 077):
|
|
401
|
-
* a number already confirmed on another device throws 409
|
|
402
|
-
* `device_not_allowed` until an admin allows the new one.
|
|
403
|
-
*/
|
|
404
|
-
confirmPhoneVerification(verificationId: string, code: string, device?: {
|
|
405
|
-
deviceKey: string;
|
|
406
|
-
platform: 'ios' | 'android' | 'web';
|
|
407
|
-
}): Promise<PhoneConfirmResponse>;
|
|
442
|
+
createAppLink(input: {
|
|
443
|
+
projectId?: string;
|
|
444
|
+
platform?: 'ios' | 'android' | 'web';
|
|
445
|
+
}): Promise<AppLinkResponse>;
|
|
408
446
|
getCompensation(): Promise<CompensationWallet>;
|
|
409
447
|
recordPaidWork(command: WorkCommand): Promise<PaidAssignment>;
|
|
410
448
|
registerCompensationPush(registration: PushRegistration): Promise<void>;
|
|
@@ -468,7 +506,7 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
468
506
|
*
|
|
469
507
|
* RAG over the project's knowledge-base markdown files. Embeds the
|
|
470
508
|
* question, retrieves top-K nearest chunks via pgvector cosine
|
|
471
|
-
* similarity, and asks gpt-
|
|
509
|
+
* similarity, and asks gpt-6-luna to synthesise an answer that
|
|
472
510
|
* STRICTLY cites those chunks. Answer language tracks the
|
|
473
511
|
* question (English / German).
|
|
474
512
|
*
|
|
@@ -520,7 +558,7 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
520
558
|
* Contract: wire.bug_reports.voiceExtractBugFields
|
|
521
559
|
*
|
|
522
560
|
* Sends base64-encoded audio to the server. The server runs Whisper
|
|
523
|
-
* (transcription) + gpt-
|
|
561
|
+
* (transcription) + gpt-6-luna (structured extraction) and returns
|
|
524
562
|
* pre-filled bug-report fields in the tester's language.
|
|
525
563
|
*
|
|
526
564
|
* Wire body uses snake_case per contract. Timeout is 60 s because
|
|
@@ -558,7 +596,7 @@ interface KnowledgeBaseAnswer {
|
|
|
558
596
|
citations: KnowledgeBaseCitation[];
|
|
559
597
|
/** Resolved project UUID — useful for telemetry / dedup. */
|
|
560
598
|
projectId: string;
|
|
561
|
-
/** Echo of the model used for the answer (e.g. "gpt-
|
|
599
|
+
/** Echo of the model used for the answer (e.g. "gpt-6-luna"). */
|
|
562
600
|
model?: string;
|
|
563
601
|
}
|
|
564
602
|
interface KnowledgeBaseCitation {
|
|
@@ -827,17 +865,13 @@ interface TesterProfile {
|
|
|
827
865
|
status?: string;
|
|
828
866
|
createdAt?: string;
|
|
829
867
|
}
|
|
830
|
-
interface
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
handle: string;
|
|
838
|
-
phoneVerified: boolean;
|
|
839
|
-
/** Tester status after the confirmation (e.g. `active`, `pending`). */
|
|
840
|
-
status?: string | null;
|
|
868
|
+
interface AppLinkResponse {
|
|
869
|
+
code: string;
|
|
870
|
+
/** Web page: opens the TPK app via universal link, else an install hint. */
|
|
871
|
+
url: string;
|
|
872
|
+
/** testerpaykit://link/<code>, opens the TPK app directly. */
|
|
873
|
+
appUrl: string;
|
|
874
|
+
expiresAt: string;
|
|
841
875
|
}
|
|
842
876
|
interface TesterPoints {
|
|
843
877
|
total: number;
|
|
@@ -943,5 +977,5 @@ interface TaskStep {
|
|
|
943
977
|
estimatedMinutes?: number | null;
|
|
944
978
|
}
|
|
945
979
|
|
|
946
|
-
export { TesterPayKitApiClient };
|
|
947
|
-
export type { AnonymousLoginResponse, ApiClientConfig, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord,
|
|
980
|
+
export { ClientOutdatedError, TPK_CLIENT_HEADER, TesterPayKitApiClient, parseClientOutdated };
|
|
981
|
+
export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
|
package/dist/index.d.ts
CHANGED
|
@@ -162,7 +162,37 @@ interface ApiClientConfig {
|
|
|
162
162
|
baseURL?: string;
|
|
163
163
|
apiKey: string;
|
|
164
164
|
tokenManager?: TokenManager;
|
|
165
|
+
/**
|
|
166
|
+
* Sent as `X-TPK-Client` on every request, e.g. `expo/2.2.0` (decision
|
|
167
|
+
* 2026-11-14 "Mindestversion je Client-Art"). Default none: the server
|
|
168
|
+
* then serves the request without a version check.
|
|
169
|
+
*/
|
|
170
|
+
clientHeader?: string;
|
|
171
|
+
}
|
|
172
|
+
/** Request header a client identifies itself with (`<kind>/<version>`). */
|
|
173
|
+
declare const TPK_CLIENT_HEADER = "X-TPK-Client";
|
|
174
|
+
/** Body of a 426 `client_outdated` answer: this client is below the
|
|
175
|
+
* minimum version the server still serves. Fields are null when the
|
|
176
|
+
* request carried no `X-TPK-Client`. */
|
|
177
|
+
interface ClientOutdatedInfo {
|
|
178
|
+
kind: string | null;
|
|
179
|
+
min: string | null;
|
|
180
|
+
yours: string | null;
|
|
181
|
+
message: string | null;
|
|
165
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Thrown instead of sending, for every request after a 426
|
|
185
|
+
* `client_outdated` (see `TesterPayKitApiClient.clientOutdated`). It has
|
|
186
|
+
* no `response`, so callers that retry on network errors keep their
|
|
187
|
+
* queued work for a newer build instead of dropping it.
|
|
188
|
+
*/
|
|
189
|
+
declare class ClientOutdatedError extends Error {
|
|
190
|
+
readonly info: ClientOutdatedInfo;
|
|
191
|
+
readonly code = "TPK_CLIENT_OUTDATED";
|
|
192
|
+
constructor(info: ClientOutdatedInfo);
|
|
193
|
+
}
|
|
194
|
+
/** The `client_outdated` body of a 426 answer, else null. */
|
|
195
|
+
declare function parseClientOutdated(status: number | undefined, body: unknown): ClientOutdatedInfo | null;
|
|
166
196
|
/**
|
|
167
197
|
* TesterPayKit API Client implementation using Axios.
|
|
168
198
|
*
|
|
@@ -183,6 +213,20 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
183
213
|
* tester UI on it. The request still rejects as before.
|
|
184
214
|
*/
|
|
185
215
|
onTesterGate: ((reason: TesterGateReason) => void) | null;
|
|
216
|
+
/**
|
|
217
|
+
* Called once, on the first 426 `client_outdated` answer. From then on
|
|
218
|
+
* this client sends nothing: every request rejects with
|
|
219
|
+
* [ClientOutdatedError] before it reaches the network.
|
|
220
|
+
*/
|
|
221
|
+
onClientOutdated: ((info: ClientOutdatedInfo) => void) | null;
|
|
222
|
+
private outdated;
|
|
223
|
+
/** Set after a 426 `client_outdated`; null while the server serves us. */
|
|
224
|
+
get clientOutdated(): ClientOutdatedInfo | null;
|
|
225
|
+
/**
|
|
226
|
+
* Blocks this client as if it had received the 426 itself (an earlier
|
|
227
|
+
* client in the same app run did). Does not call [onClientOutdated].
|
|
228
|
+
*/
|
|
229
|
+
markClientOutdated(info: ClientOutdatedInfo): void;
|
|
186
230
|
constructor(config: ApiClientConfig);
|
|
187
231
|
/**
|
|
188
232
|
* Setup request/response interceptors for JWT authentication.
|
|
@@ -389,22 +433,16 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
389
433
|
*/
|
|
390
434
|
getMyProfile(): Promise<TesterProfile>;
|
|
391
435
|
/**
|
|
392
|
-
* POST /v1/testers/me/phone/
|
|
393
|
-
*
|
|
394
|
-
*
|
|
436
|
+
* POST /v1/testers/me/phone/link — a short-lived code for confirming this
|
|
437
|
+
* install in the TPK app (decision 2026-11-10, replaces the SMS dialog).
|
|
438
|
+
* Open `appUrl` (TPK app installed) or `url` (web page with an install
|
|
439
|
+
* hint); the person allows it there, then GET /v1/testers/me/profile
|
|
440
|
+
* reports the install as confirmed.
|
|
395
441
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
* `device` binds the number to this physical device (migration 077):
|
|
401
|
-
* a number already confirmed on another device throws 409
|
|
402
|
-
* `device_not_allowed` until an admin allows the new one.
|
|
403
|
-
*/
|
|
404
|
-
confirmPhoneVerification(verificationId: string, code: string, device?: {
|
|
405
|
-
deviceKey: string;
|
|
406
|
-
platform: 'ios' | 'android' | 'web';
|
|
407
|
-
}): Promise<PhoneConfirmResponse>;
|
|
442
|
+
createAppLink(input: {
|
|
443
|
+
projectId?: string;
|
|
444
|
+
platform?: 'ios' | 'android' | 'web';
|
|
445
|
+
}): Promise<AppLinkResponse>;
|
|
408
446
|
getCompensation(): Promise<CompensationWallet>;
|
|
409
447
|
recordPaidWork(command: WorkCommand): Promise<PaidAssignment>;
|
|
410
448
|
registerCompensationPush(registration: PushRegistration): Promise<void>;
|
|
@@ -468,7 +506,7 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
468
506
|
*
|
|
469
507
|
* RAG over the project's knowledge-base markdown files. Embeds the
|
|
470
508
|
* question, retrieves top-K nearest chunks via pgvector cosine
|
|
471
|
-
* similarity, and asks gpt-
|
|
509
|
+
* similarity, and asks gpt-6-luna to synthesise an answer that
|
|
472
510
|
* STRICTLY cites those chunks. Answer language tracks the
|
|
473
511
|
* question (English / German).
|
|
474
512
|
*
|
|
@@ -520,7 +558,7 @@ declare class TesterPayKitApiClient implements IApiClient {
|
|
|
520
558
|
* Contract: wire.bug_reports.voiceExtractBugFields
|
|
521
559
|
*
|
|
522
560
|
* Sends base64-encoded audio to the server. The server runs Whisper
|
|
523
|
-
* (transcription) + gpt-
|
|
561
|
+
* (transcription) + gpt-6-luna (structured extraction) and returns
|
|
524
562
|
* pre-filled bug-report fields in the tester's language.
|
|
525
563
|
*
|
|
526
564
|
* Wire body uses snake_case per contract. Timeout is 60 s because
|
|
@@ -558,7 +596,7 @@ interface KnowledgeBaseAnswer {
|
|
|
558
596
|
citations: KnowledgeBaseCitation[];
|
|
559
597
|
/** Resolved project UUID — useful for telemetry / dedup. */
|
|
560
598
|
projectId: string;
|
|
561
|
-
/** Echo of the model used for the answer (e.g. "gpt-
|
|
599
|
+
/** Echo of the model used for the answer (e.g. "gpt-6-luna"). */
|
|
562
600
|
model?: string;
|
|
563
601
|
}
|
|
564
602
|
interface KnowledgeBaseCitation {
|
|
@@ -827,17 +865,13 @@ interface TesterProfile {
|
|
|
827
865
|
status?: string;
|
|
828
866
|
createdAt?: string;
|
|
829
867
|
}
|
|
830
|
-
interface
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
handle: string;
|
|
838
|
-
phoneVerified: boolean;
|
|
839
|
-
/** Tester status after the confirmation (e.g. `active`, `pending`). */
|
|
840
|
-
status?: string | null;
|
|
868
|
+
interface AppLinkResponse {
|
|
869
|
+
code: string;
|
|
870
|
+
/** Web page: opens the TPK app via universal link, else an install hint. */
|
|
871
|
+
url: string;
|
|
872
|
+
/** testerpaykit://link/<code>, opens the TPK app directly. */
|
|
873
|
+
appUrl: string;
|
|
874
|
+
expiresAt: string;
|
|
841
875
|
}
|
|
842
876
|
interface TesterPoints {
|
|
843
877
|
total: number;
|
|
@@ -943,5 +977,5 @@ interface TaskStep {
|
|
|
943
977
|
estimatedMinutes?: number | null;
|
|
944
978
|
}
|
|
945
979
|
|
|
946
|
-
export { TesterPayKitApiClient };
|
|
947
|
-
export type { AnonymousLoginResponse, ApiClientConfig, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord,
|
|
980
|
+
export { ClientOutdatedError, TPK_CLIENT_HEADER, TesterPayKitApiClient, parseClientOutdated };
|
|
981
|
+
export type { AnonymousLoginResponse, ApiClientConfig, AppLinkResponse, BugCategory, BugReportAttachmentInput, BugReportAttachmentResponse, BugReportPayload, BugReportResponse, BugReportType, BugSeverity, ChecklistRun, ChecklistRunInput, ChecklistStepResult, ChecklistTask, ClientOutdatedInfo, CompensationRates, CompensationWallet, EarningsSummary, EndTesterSessionInput, EnrollmentResponse, KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeFile, KnowledgeFileSummary, LiveNoteInput, MoneyEntry, MoneyKind, MoneyMode, MoneyTotals, MyBugReportSummary, MyBugReportsResponse, NotificationsResult, PaidAssignment, PayoutRecord, PushRegistration, RegisterDeviceInput, RetestItem, RetestStepVerdicts, SdkUpdateInfo, SessionBreadcrumbInput, SessionBreadcrumbsResponse, SessionEventInput, SessionEventsResponse, StartTesterSessionInput, SubmissionResponse, TaskListFilter, TaskListResponse, TaskPreset, TaskStep, TesterDeviceResponse, TesterGateReason, TesterPoints, TesterProfile, TesterSessionEndReason, TesterSessionResponse, TesterTask, TpkNotification, WorkCommand, WorkState };
|
package/dist/index.js
CHANGED
|
@@ -30,13 +30,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
33
|
+
ClientOutdatedError: () => ClientOutdatedError,
|
|
34
|
+
TPK_CLIENT_HEADER: () => TPK_CLIENT_HEADER,
|
|
35
|
+
TesterPayKitApiClient: () => TesterPayKitApiClient,
|
|
36
|
+
parseClientOutdated: () => parseClientOutdated
|
|
34
37
|
});
|
|
35
38
|
module.exports = __toCommonJS(index_exports);
|
|
36
39
|
|
|
37
40
|
// src/TesterPayKitApiClient.ts
|
|
38
41
|
var import_axios = __toESM(require("axios"));
|
|
39
42
|
var import_core = require("@testerpaykit/core");
|
|
43
|
+
var TPK_CLIENT_HEADER = "X-TPK-Client";
|
|
44
|
+
var ClientOutdatedError = class extends Error {
|
|
45
|
+
constructor(info) {
|
|
46
|
+
super(info.message ?? "TesterPayKit client is too old for the server.");
|
|
47
|
+
this.info = info;
|
|
48
|
+
this.code = "TPK_CLIENT_OUTDATED";
|
|
49
|
+
this.name = "ClientOutdatedError";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function parseClientOutdated(status, body) {
|
|
53
|
+
if (status !== 426 || typeof body !== "object" || body === null) return null;
|
|
54
|
+
const b = body;
|
|
55
|
+
if (b.error !== "client_outdated") return null;
|
|
56
|
+
const str = (v) => typeof v === "string" ? v : null;
|
|
57
|
+
return { kind: str(b.kind), min: str(b.min), yours: str(b.yours), message: str(b.message) };
|
|
58
|
+
}
|
|
40
59
|
var TesterPayKitApiClient = class {
|
|
41
60
|
constructor(config) {
|
|
42
61
|
/**
|
|
@@ -45,22 +64,43 @@ var TesterPayKitApiClient = class {
|
|
|
45
64
|
* tester UI on it. The request still rejects as before.
|
|
46
65
|
*/
|
|
47
66
|
this.onTesterGate = null;
|
|
67
|
+
/**
|
|
68
|
+
* Called once, on the first 426 `client_outdated` answer. From then on
|
|
69
|
+
* this client sends nothing: every request rejects with
|
|
70
|
+
* [ClientOutdatedError] before it reaches the network.
|
|
71
|
+
*/
|
|
72
|
+
this.onClientOutdated = null;
|
|
73
|
+
this.outdated = null;
|
|
48
74
|
this.apiKey = config.apiKey;
|
|
49
75
|
this.tokenManager = config.tokenManager || new import_core.TokenManager();
|
|
76
|
+
const headers = {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
"X-API-Key": this.apiKey
|
|
79
|
+
};
|
|
80
|
+
if (config.clientHeader) headers[TPK_CLIENT_HEADER] = config.clientHeader;
|
|
50
81
|
this.client = import_axios.default.create({
|
|
51
82
|
baseURL: config.baseURL || "https://api.testerpaykit.com",
|
|
52
|
-
headers
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
"X-API-Key": this.apiKey
|
|
55
|
-
}
|
|
83
|
+
headers
|
|
56
84
|
});
|
|
57
85
|
this.setupInterceptors();
|
|
58
86
|
}
|
|
87
|
+
/** Set after a 426 `client_outdated`; null while the server serves us. */
|
|
88
|
+
get clientOutdated() {
|
|
89
|
+
return this.outdated;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Blocks this client as if it had received the 426 itself (an earlier
|
|
93
|
+
* client in the same app run did). Does not call [onClientOutdated].
|
|
94
|
+
*/
|
|
95
|
+
markClientOutdated(info) {
|
|
96
|
+
this.outdated ?? (this.outdated = info);
|
|
97
|
+
}
|
|
59
98
|
/**
|
|
60
99
|
* Setup request/response interceptors for JWT authentication.
|
|
61
100
|
*/
|
|
62
101
|
setupInterceptors() {
|
|
63
102
|
this.client.interceptors.request.use(async (config) => {
|
|
103
|
+
if (this.outdated) throw new ClientOutdatedError(this.outdated);
|
|
64
104
|
const token = await this.tokenManager.ensureValidToken();
|
|
65
105
|
if (token) {
|
|
66
106
|
config.headers.Authorization = `Bearer ${token}`;
|
|
@@ -73,6 +113,14 @@ var TesterPayKitApiClient = class {
|
|
|
73
113
|
if (error.response?.status === 401) {
|
|
74
114
|
this.tokenManager.clear();
|
|
75
115
|
}
|
|
116
|
+
const outdated = parseClientOutdated(error.response?.status, error.response?.data);
|
|
117
|
+
if (outdated && !this.outdated) {
|
|
118
|
+
this.outdated = outdated;
|
|
119
|
+
try {
|
|
120
|
+
this.onClientOutdated?.(outdated);
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
}
|
|
76
124
|
const code = error.response?.data?.error;
|
|
77
125
|
if (error.response?.status === 403 && (code === "phone_required" || code === "approval_required")) {
|
|
78
126
|
try {
|
|
@@ -478,28 +526,16 @@ var TesterPayKitApiClient = class {
|
|
|
478
526
|
return response.data;
|
|
479
527
|
}
|
|
480
528
|
/**
|
|
481
|
-
* POST /v1/testers/me/phone/
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const response = await this.client.post(
|
|
487
|
-
"/v1/testers/me/phone/start",
|
|
488
|
-
{ phone }
|
|
489
|
-
);
|
|
490
|
-
return response.data;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
494
|
-
* tester's handle; the same number on another install hands it over.
|
|
495
|
-
* `device` binds the number to this physical device (migration 077):
|
|
496
|
-
* a number already confirmed on another device throws 409
|
|
497
|
-
* `device_not_allowed` until an admin allows the new one.
|
|
529
|
+
* POST /v1/testers/me/phone/link — a short-lived code for confirming this
|
|
530
|
+
* install in the TPK app (decision 2026-11-10, replaces the SMS dialog).
|
|
531
|
+
* Open `appUrl` (TPK app installed) or `url` (web page with an install
|
|
532
|
+
* hint); the person allows it there, then GET /v1/testers/me/profile
|
|
533
|
+
* reports the install as confirmed.
|
|
498
534
|
*/
|
|
499
|
-
async
|
|
535
|
+
async createAppLink(input) {
|
|
500
536
|
const response = await this.client.post(
|
|
501
|
-
"/v1/testers/me/phone/
|
|
502
|
-
|
|
537
|
+
"/v1/testers/me/phone/link",
|
|
538
|
+
input
|
|
503
539
|
);
|
|
504
540
|
return response.data;
|
|
505
541
|
}
|
|
@@ -590,7 +626,7 @@ var TesterPayKitApiClient = class {
|
|
|
590
626
|
*
|
|
591
627
|
* RAG over the project's knowledge-base markdown files. Embeds the
|
|
592
628
|
* question, retrieves top-K nearest chunks via pgvector cosine
|
|
593
|
-
* similarity, and asks gpt-
|
|
629
|
+
* similarity, and asks gpt-6-luna to synthesise an answer that
|
|
594
630
|
* STRICTLY cites those chunks. Answer language tracks the
|
|
595
631
|
* question (English / German).
|
|
596
632
|
*
|
|
@@ -682,7 +718,7 @@ var TesterPayKitApiClient = class {
|
|
|
682
718
|
* Contract: wire.bug_reports.voiceExtractBugFields
|
|
683
719
|
*
|
|
684
720
|
* Sends base64-encoded audio to the server. The server runs Whisper
|
|
685
|
-
* (transcription) + gpt-
|
|
721
|
+
* (transcription) + gpt-6-luna (structured extraction) and returns
|
|
686
722
|
* pre-filled bug-report fields in the tester's language.
|
|
687
723
|
*
|
|
688
724
|
* Wire body uses snake_case per contract. Timeout is 60 s because
|
|
@@ -746,5 +782,8 @@ function assertSessionId(sessionId, op) {
|
|
|
746
782
|
}
|
|
747
783
|
// Annotate the CommonJS export names for ESM import in node:
|
|
748
784
|
0 && (module.exports = {
|
|
749
|
-
|
|
785
|
+
ClientOutdatedError,
|
|
786
|
+
TPK_CLIENT_HEADER,
|
|
787
|
+
TesterPayKitApiClient,
|
|
788
|
+
parseClientOutdated
|
|
750
789
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,22 @@ import axios from "axios";
|
|
|
3
3
|
import {
|
|
4
4
|
TokenManager
|
|
5
5
|
} from "@testerpaykit/core";
|
|
6
|
+
var TPK_CLIENT_HEADER = "X-TPK-Client";
|
|
7
|
+
var ClientOutdatedError = class extends Error {
|
|
8
|
+
constructor(info) {
|
|
9
|
+
super(info.message ?? "TesterPayKit client is too old for the server.");
|
|
10
|
+
this.info = info;
|
|
11
|
+
this.code = "TPK_CLIENT_OUTDATED";
|
|
12
|
+
this.name = "ClientOutdatedError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
function parseClientOutdated(status, body) {
|
|
16
|
+
if (status !== 426 || typeof body !== "object" || body === null) return null;
|
|
17
|
+
const b = body;
|
|
18
|
+
if (b.error !== "client_outdated") return null;
|
|
19
|
+
const str = (v) => typeof v === "string" ? v : null;
|
|
20
|
+
return { kind: str(b.kind), min: str(b.min), yours: str(b.yours), message: str(b.message) };
|
|
21
|
+
}
|
|
6
22
|
var TesterPayKitApiClient = class {
|
|
7
23
|
constructor(config) {
|
|
8
24
|
/**
|
|
@@ -11,22 +27,43 @@ var TesterPayKitApiClient = class {
|
|
|
11
27
|
* tester UI on it. The request still rejects as before.
|
|
12
28
|
*/
|
|
13
29
|
this.onTesterGate = null;
|
|
30
|
+
/**
|
|
31
|
+
* Called once, on the first 426 `client_outdated` answer. From then on
|
|
32
|
+
* this client sends nothing: every request rejects with
|
|
33
|
+
* [ClientOutdatedError] before it reaches the network.
|
|
34
|
+
*/
|
|
35
|
+
this.onClientOutdated = null;
|
|
36
|
+
this.outdated = null;
|
|
14
37
|
this.apiKey = config.apiKey;
|
|
15
38
|
this.tokenManager = config.tokenManager || new TokenManager();
|
|
39
|
+
const headers = {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
"X-API-Key": this.apiKey
|
|
42
|
+
};
|
|
43
|
+
if (config.clientHeader) headers[TPK_CLIENT_HEADER] = config.clientHeader;
|
|
16
44
|
this.client = axios.create({
|
|
17
45
|
baseURL: config.baseURL || "https://api.testerpaykit.com",
|
|
18
|
-
headers
|
|
19
|
-
"Content-Type": "application/json",
|
|
20
|
-
"X-API-Key": this.apiKey
|
|
21
|
-
}
|
|
46
|
+
headers
|
|
22
47
|
});
|
|
23
48
|
this.setupInterceptors();
|
|
24
49
|
}
|
|
50
|
+
/** Set after a 426 `client_outdated`; null while the server serves us. */
|
|
51
|
+
get clientOutdated() {
|
|
52
|
+
return this.outdated;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Blocks this client as if it had received the 426 itself (an earlier
|
|
56
|
+
* client in the same app run did). Does not call [onClientOutdated].
|
|
57
|
+
*/
|
|
58
|
+
markClientOutdated(info) {
|
|
59
|
+
this.outdated ?? (this.outdated = info);
|
|
60
|
+
}
|
|
25
61
|
/**
|
|
26
62
|
* Setup request/response interceptors for JWT authentication.
|
|
27
63
|
*/
|
|
28
64
|
setupInterceptors() {
|
|
29
65
|
this.client.interceptors.request.use(async (config) => {
|
|
66
|
+
if (this.outdated) throw new ClientOutdatedError(this.outdated);
|
|
30
67
|
const token = await this.tokenManager.ensureValidToken();
|
|
31
68
|
if (token) {
|
|
32
69
|
config.headers.Authorization = `Bearer ${token}`;
|
|
@@ -39,6 +76,14 @@ var TesterPayKitApiClient = class {
|
|
|
39
76
|
if (error.response?.status === 401) {
|
|
40
77
|
this.tokenManager.clear();
|
|
41
78
|
}
|
|
79
|
+
const outdated = parseClientOutdated(error.response?.status, error.response?.data);
|
|
80
|
+
if (outdated && !this.outdated) {
|
|
81
|
+
this.outdated = outdated;
|
|
82
|
+
try {
|
|
83
|
+
this.onClientOutdated?.(outdated);
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
42
87
|
const code = error.response?.data?.error;
|
|
43
88
|
if (error.response?.status === 403 && (code === "phone_required" || code === "approval_required")) {
|
|
44
89
|
try {
|
|
@@ -444,28 +489,16 @@ var TesterPayKitApiClient = class {
|
|
|
444
489
|
return response.data;
|
|
445
490
|
}
|
|
446
491
|
/**
|
|
447
|
-
* POST /v1/testers/me/phone/
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const response = await this.client.post(
|
|
453
|
-
"/v1/testers/me/phone/start",
|
|
454
|
-
{ phone }
|
|
455
|
-
);
|
|
456
|
-
return response.data;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
460
|
-
* tester's handle; the same number on another install hands it over.
|
|
461
|
-
* `device` binds the number to this physical device (migration 077):
|
|
462
|
-
* a number already confirmed on another device throws 409
|
|
463
|
-
* `device_not_allowed` until an admin allows the new one.
|
|
492
|
+
* POST /v1/testers/me/phone/link — a short-lived code for confirming this
|
|
493
|
+
* install in the TPK app (decision 2026-11-10, replaces the SMS dialog).
|
|
494
|
+
* Open `appUrl` (TPK app installed) or `url` (web page with an install
|
|
495
|
+
* hint); the person allows it there, then GET /v1/testers/me/profile
|
|
496
|
+
* reports the install as confirmed.
|
|
464
497
|
*/
|
|
465
|
-
async
|
|
498
|
+
async createAppLink(input) {
|
|
466
499
|
const response = await this.client.post(
|
|
467
|
-
"/v1/testers/me/phone/
|
|
468
|
-
|
|
500
|
+
"/v1/testers/me/phone/link",
|
|
501
|
+
input
|
|
469
502
|
);
|
|
470
503
|
return response.data;
|
|
471
504
|
}
|
|
@@ -556,7 +589,7 @@ var TesterPayKitApiClient = class {
|
|
|
556
589
|
*
|
|
557
590
|
* RAG over the project's knowledge-base markdown files. Embeds the
|
|
558
591
|
* question, retrieves top-K nearest chunks via pgvector cosine
|
|
559
|
-
* similarity, and asks gpt-
|
|
592
|
+
* similarity, and asks gpt-6-luna to synthesise an answer that
|
|
560
593
|
* STRICTLY cites those chunks. Answer language tracks the
|
|
561
594
|
* question (English / German).
|
|
562
595
|
*
|
|
@@ -648,7 +681,7 @@ var TesterPayKitApiClient = class {
|
|
|
648
681
|
* Contract: wire.bug_reports.voiceExtractBugFields
|
|
649
682
|
*
|
|
650
683
|
* Sends base64-encoded audio to the server. The server runs Whisper
|
|
651
|
-
* (transcription) + gpt-
|
|
684
|
+
* (transcription) + gpt-6-luna (structured extraction) and returns
|
|
652
685
|
* pre-filled bug-report fields in the tester's language.
|
|
653
686
|
*
|
|
654
687
|
* Wire body uses snake_case per contract. Timeout is 60 s because
|
|
@@ -711,5 +744,8 @@ function assertSessionId(sessionId, op) {
|
|
|
711
744
|
}
|
|
712
745
|
}
|
|
713
746
|
export {
|
|
714
|
-
|
|
747
|
+
ClientOutdatedError,
|
|
748
|
+
TPK_CLIENT_HEADER,
|
|
749
|
+
TesterPayKitApiClient,
|
|
750
|
+
parseClientOutdated
|
|
715
751
|
};
|
package/package.json
CHANGED
|
@@ -61,6 +61,51 @@ export interface ApiClientConfig {
|
|
|
61
61
|
baseURL?: string;
|
|
62
62
|
apiKey: string;
|
|
63
63
|
tokenManager?: TokenManager;
|
|
64
|
+
/**
|
|
65
|
+
* Sent as `X-TPK-Client` on every request, e.g. `expo/2.2.0` (decision
|
|
66
|
+
* 2026-11-14 "Mindestversion je Client-Art"). Default none: the server
|
|
67
|
+
* then serves the request without a version check.
|
|
68
|
+
*/
|
|
69
|
+
clientHeader?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Request header a client identifies itself with (`<kind>/<version>`). */
|
|
73
|
+
export const TPK_CLIENT_HEADER = 'X-TPK-Client';
|
|
74
|
+
|
|
75
|
+
/** Body of a 426 `client_outdated` answer: this client is below the
|
|
76
|
+
* minimum version the server still serves. Fields are null when the
|
|
77
|
+
* request carried no `X-TPK-Client`. */
|
|
78
|
+
export interface ClientOutdatedInfo {
|
|
79
|
+
kind: string | null;
|
|
80
|
+
min: string | null;
|
|
81
|
+
yours: string | null;
|
|
82
|
+
message: string | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Thrown instead of sending, for every request after a 426
|
|
87
|
+
* `client_outdated` (see `TesterPayKitApiClient.clientOutdated`). It has
|
|
88
|
+
* no `response`, so callers that retry on network errors keep their
|
|
89
|
+
* queued work for a newer build instead of dropping it.
|
|
90
|
+
*/
|
|
91
|
+
export class ClientOutdatedError extends Error {
|
|
92
|
+
readonly code = 'TPK_CLIENT_OUTDATED';
|
|
93
|
+
constructor(readonly info: ClientOutdatedInfo) {
|
|
94
|
+
super(info.message ?? 'TesterPayKit client is too old for the server.');
|
|
95
|
+
this.name = 'ClientOutdatedError';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The `client_outdated` body of a 426 answer, else null. */
|
|
100
|
+
export function parseClientOutdated(
|
|
101
|
+
status: number | undefined,
|
|
102
|
+
body: unknown,
|
|
103
|
+
): ClientOutdatedInfo | null {
|
|
104
|
+
if (status !== 426 || typeof body !== 'object' || body === null) return null;
|
|
105
|
+
const b = body as Record<string, unknown>;
|
|
106
|
+
if (b.error !== 'client_outdated') return null;
|
|
107
|
+
const str = (v: unknown) => (typeof v === 'string' ? v : null);
|
|
108
|
+
return { kind: str(b.kind), min: str(b.min), yours: str(b.yours), message: str(b.message) };
|
|
64
109
|
}
|
|
65
110
|
|
|
66
111
|
/**
|
|
@@ -86,16 +131,40 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
86
131
|
*/
|
|
87
132
|
onTesterGate: ((reason: TesterGateReason) => void) | null = null;
|
|
88
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Called once, on the first 426 `client_outdated` answer. From then on
|
|
136
|
+
* this client sends nothing: every request rejects with
|
|
137
|
+
* [ClientOutdatedError] before it reaches the network.
|
|
138
|
+
*/
|
|
139
|
+
onClientOutdated: ((info: ClientOutdatedInfo) => void) | null = null;
|
|
140
|
+
|
|
141
|
+
private outdated: ClientOutdatedInfo | null = null;
|
|
142
|
+
|
|
143
|
+
/** Set after a 426 `client_outdated`; null while the server serves us. */
|
|
144
|
+
get clientOutdated(): ClientOutdatedInfo | null {
|
|
145
|
+
return this.outdated;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Blocks this client as if it had received the 426 itself (an earlier
|
|
150
|
+
* client in the same app run did). Does not call [onClientOutdated].
|
|
151
|
+
*/
|
|
152
|
+
markClientOutdated(info: ClientOutdatedInfo): void {
|
|
153
|
+
this.outdated ??= info;
|
|
154
|
+
}
|
|
155
|
+
|
|
89
156
|
constructor(config: ApiClientConfig) {
|
|
90
157
|
this.apiKey = config.apiKey;
|
|
91
158
|
this.tokenManager = config.tokenManager || new TokenManager();
|
|
92
159
|
|
|
160
|
+
const headers: Record<string, string> = {
|
|
161
|
+
'Content-Type': 'application/json',
|
|
162
|
+
'X-API-Key': this.apiKey,
|
|
163
|
+
};
|
|
164
|
+
if (config.clientHeader) headers[TPK_CLIENT_HEADER] = config.clientHeader;
|
|
93
165
|
this.client = axios.create({
|
|
94
166
|
baseURL: config.baseURL || 'https://api.testerpaykit.com',
|
|
95
|
-
headers
|
|
96
|
-
'Content-Type': 'application/json',
|
|
97
|
-
'X-API-Key': this.apiKey,
|
|
98
|
-
},
|
|
167
|
+
headers,
|
|
99
168
|
});
|
|
100
169
|
|
|
101
170
|
this.setupInterceptors();
|
|
@@ -107,6 +176,8 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
107
176
|
private setupInterceptors(): void {
|
|
108
177
|
// Request interceptor: Add auth token to every request
|
|
109
178
|
this.client.interceptors.request.use(async (config) => {
|
|
179
|
+
// Too old for the server: nothing more goes out in this app run.
|
|
180
|
+
if (this.outdated) throw new ClientOutdatedError(this.outdated);
|
|
110
181
|
const token = await this.tokenManager.ensureValidToken();
|
|
111
182
|
if (token) {
|
|
112
183
|
config.headers.Authorization = `Bearer ${token}`;
|
|
@@ -122,6 +193,15 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
122
193
|
// Token expired or invalid, clear tokens
|
|
123
194
|
this.tokenManager.clear();
|
|
124
195
|
}
|
|
196
|
+
const outdated = parseClientOutdated(error.response?.status, error.response?.data);
|
|
197
|
+
if (outdated && !this.outdated) {
|
|
198
|
+
this.outdated = outdated;
|
|
199
|
+
try {
|
|
200
|
+
this.onClientOutdated?.(outdated);
|
|
201
|
+
} catch {
|
|
202
|
+
// A listener problem must not change the request's outcome.
|
|
203
|
+
}
|
|
204
|
+
}
|
|
125
205
|
const code = error.response?.data?.error;
|
|
126
206
|
if (
|
|
127
207
|
error.response?.status === 403 &&
|
|
@@ -629,33 +709,19 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
629
709
|
}
|
|
630
710
|
|
|
631
711
|
/**
|
|
632
|
-
* POST /v1/testers/me/phone/
|
|
633
|
-
*
|
|
634
|
-
*
|
|
712
|
+
* POST /v1/testers/me/phone/link — a short-lived code for confirming this
|
|
713
|
+
* install in the TPK app (decision 2026-11-10, replaces the SMS dialog).
|
|
714
|
+
* Open `appUrl` (TPK app installed) or `url` (web page with an install
|
|
715
|
+
* hint); the person allows it there, then GET /v1/testers/me/profile
|
|
716
|
+
* reports the install as confirmed.
|
|
635
717
|
*/
|
|
636
|
-
async
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* POST /v1/testers/me/phone/confirm — confirms the code. Returns the
|
|
646
|
-
* tester's handle; the same number on another install hands it over.
|
|
647
|
-
* `device` binds the number to this physical device (migration 077):
|
|
648
|
-
* a number already confirmed on another device throws 409
|
|
649
|
-
* `device_not_allowed` until an admin allows the new one.
|
|
650
|
-
*/
|
|
651
|
-
async confirmPhoneVerification(
|
|
652
|
-
verificationId: string,
|
|
653
|
-
code: string,
|
|
654
|
-
device?: { deviceKey: string; platform: 'ios' | 'android' | 'web' },
|
|
655
|
-
): Promise<PhoneConfirmResponse> {
|
|
656
|
-
const response = await this.client.post<PhoneConfirmResponse>(
|
|
657
|
-
'/v1/testers/me/phone/confirm',
|
|
658
|
-
{ verificationId, code, ...device },
|
|
718
|
+
async createAppLink(input: {
|
|
719
|
+
projectId?: string;
|
|
720
|
+
platform?: 'ios' | 'android' | 'web';
|
|
721
|
+
}): Promise<AppLinkResponse> {
|
|
722
|
+
const response = await this.client.post<AppLinkResponse>(
|
|
723
|
+
'/v1/testers/me/phone/link',
|
|
724
|
+
input,
|
|
659
725
|
);
|
|
660
726
|
return response.data;
|
|
661
727
|
}
|
|
@@ -778,7 +844,7 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
778
844
|
*
|
|
779
845
|
* RAG over the project's knowledge-base markdown files. Embeds the
|
|
780
846
|
* question, retrieves top-K nearest chunks via pgvector cosine
|
|
781
|
-
* similarity, and asks gpt-
|
|
847
|
+
* similarity, and asks gpt-6-luna to synthesise an answer that
|
|
782
848
|
* STRICTLY cites those chunks. Answer language tracks the
|
|
783
849
|
* question (English / German).
|
|
784
850
|
*
|
|
@@ -886,7 +952,7 @@ export class TesterPayKitApiClient implements IApiClient {
|
|
|
886
952
|
* Contract: wire.bug_reports.voiceExtractBugFields
|
|
887
953
|
*
|
|
888
954
|
* Sends base64-encoded audio to the server. The server runs Whisper
|
|
889
|
-
* (transcription) + gpt-
|
|
955
|
+
* (transcription) + gpt-6-luna (structured extraction) and returns
|
|
890
956
|
* pre-filled bug-report fields in the tester's language.
|
|
891
957
|
*
|
|
892
958
|
* Wire body uses snake_case per contract. Timeout is 60 s because
|
|
@@ -962,7 +1028,7 @@ export interface KnowledgeBaseAnswer {
|
|
|
962
1028
|
citations: KnowledgeBaseCitation[];
|
|
963
1029
|
/** Resolved project UUID — useful for telemetry / dedup. */
|
|
964
1030
|
projectId: string;
|
|
965
|
-
/** Echo of the model used for the answer (e.g. "gpt-
|
|
1031
|
+
/** Echo of the model used for the answer (e.g. "gpt-6-luna"). */
|
|
966
1032
|
model?: string;
|
|
967
1033
|
}
|
|
968
1034
|
|
|
@@ -1287,18 +1353,13 @@ export interface TesterProfile {
|
|
|
1287
1353
|
createdAt?: string;
|
|
1288
1354
|
}
|
|
1289
1355
|
|
|
1290
|
-
export interface
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
export interface PhoneConfirmResponse {
|
|
1298
|
-
handle: string;
|
|
1299
|
-
phoneVerified: boolean;
|
|
1300
|
-
/** Tester status after the confirmation (e.g. `active`, `pending`). */
|
|
1301
|
-
status?: string | null;
|
|
1356
|
+
export interface AppLinkResponse {
|
|
1357
|
+
code: string;
|
|
1358
|
+
/** Web page: opens the TPK app via universal link, else an install hint. */
|
|
1359
|
+
url: string;
|
|
1360
|
+
/** testerpaykit://link/<code>, opens the TPK app directly. */
|
|
1361
|
+
appUrl: string;
|
|
1362
|
+
expiresAt: string;
|
|
1302
1363
|
}
|
|
1303
1364
|
|
|
1304
1365
|
export interface TesterPoints {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ClientOutdatedError,
|
|
5
|
+
TesterPayKitApiClient,
|
|
6
|
+
} from '../src/TesterPayKitApiClient';
|
|
4
7
|
import { TokenManager } from '@testerpaykit/core';
|
|
5
8
|
|
|
6
9
|
// Mock axios
|
|
@@ -95,6 +98,61 @@ describe('TesterPayKitApiClient', () => {
|
|
|
95
98
|
});
|
|
96
99
|
});
|
|
97
100
|
|
|
101
|
+
describe('client version check', () => {
|
|
102
|
+
const outdatedBody = {
|
|
103
|
+
error: 'client_outdated',
|
|
104
|
+
kind: 'expo',
|
|
105
|
+
min: '2.2.0',
|
|
106
|
+
yours: '2.1.0',
|
|
107
|
+
message: 'too old',
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
it('sends no X-TPK-Client unless the caller sets one', () => {
|
|
111
|
+
new TesterPayKitApiClient({ apiKey: 'k', clientHeader: 'expo/2.2.0' });
|
|
112
|
+
expect(mockedAxios.create).toHaveBeenLastCalledWith({
|
|
113
|
+
baseURL: 'https://api.testerpaykit.com',
|
|
114
|
+
headers: {
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
'X-API-Key': 'k',
|
|
117
|
+
'X-TPK-Client': 'expo/2.2.0',
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('426 client_outdated: reports once, then sends nothing more', async () => {
|
|
123
|
+
const onRequest = mockAxiosInstance.interceptors.request.use.mock.calls[0][0];
|
|
124
|
+
const onError = mockAxiosInstance.interceptors.response.use.mock.calls[0][1];
|
|
125
|
+
const seen: unknown[] = [];
|
|
126
|
+
client.onClientOutdated = (info) => seen.push(info);
|
|
127
|
+
|
|
128
|
+
expect(client.clientOutdated).toBeNull();
|
|
129
|
+
await expect(onRequest({ headers: {} })).resolves.toBeTruthy();
|
|
130
|
+
|
|
131
|
+
await expect(
|
|
132
|
+
onError({ response: { status: 426, data: outdatedBody } }),
|
|
133
|
+
).rejects.toBeTruthy();
|
|
134
|
+
await expect(
|
|
135
|
+
onError({ response: { status: 426, data: outdatedBody } }),
|
|
136
|
+
).rejects.toBeTruthy();
|
|
137
|
+
|
|
138
|
+
const info = { kind: 'expo', min: '2.2.0', yours: '2.1.0', message: 'too old' };
|
|
139
|
+
expect(seen).toEqual([info]);
|
|
140
|
+
expect(client.clientOutdated).toEqual(info);
|
|
141
|
+
const blocked = onRequest({ headers: {} });
|
|
142
|
+
await expect(blocked).rejects.toBeInstanceOf(ClientOutdatedError);
|
|
143
|
+
await expect(blocked).rejects.toMatchObject({ info });
|
|
144
|
+
await expect(blocked).rejects.not.toHaveProperty('response');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('ignores a 426 without client_outdated', async () => {
|
|
148
|
+
const onError = mockAxiosInstance.interceptors.response.use.mock.calls[0][1];
|
|
149
|
+
await expect(
|
|
150
|
+
onError({ response: { status: 426, data: { error: 'other' } } }),
|
|
151
|
+
).rejects.toBeTruthy();
|
|
152
|
+
expect(client.clientOutdated).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
98
156
|
describe('login', () => {
|
|
99
157
|
it('should successfully login and store tokens', async () => {
|
|
100
158
|
const loginRequest = {
|