run402 3.3.3 → 3.3.4
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/lib/transfer.mjs +68 -38
- package/package.json +1 -1
- package/sdk/dist/namespaces/admin.d.ts +3 -3
- package/sdk/dist/namespaces/admin.js +3 -3
- package/sdk/dist/namespaces/transfers.d.ts +85 -22
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +56 -41
- package/sdk/dist/namespaces/transfers.js.map +1 -1
package/lib/transfer.mjs
CHANGED
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
positionalArgs,
|
|
11
11
|
} from "./argparse.mjs";
|
|
12
12
|
|
|
13
|
-
const HELP = `run402 transfer — Project transfer, one noun for
|
|
13
|
+
const HELP = `run402 transfer — Project transfer, one noun for wallet, email, and owned-org recipients
|
|
14
14
|
|
|
15
15
|
Usage:
|
|
16
|
-
run402 transfer init --to <wallet|email> [--project <id>] [--billing-policy migrate] [--message <text>] [--kysigned <record_id>] [--retain-collaborator developer]
|
|
16
|
+
run402 transfer init (--to <wallet|email> | --to-org <org_id>) [--project <id>] [--billing-policy migrate] [--message <text>] [--kysigned <record_id>] [--retain-collaborator developer]
|
|
17
17
|
run402 transfer preview <transfer_id>
|
|
18
18
|
run402 transfer list [--incoming | --outgoing] [--limit N] [--after <cursor>]
|
|
19
19
|
run402 transfer accept <transfer_id>
|
|
@@ -22,17 +22,19 @@ Usage:
|
|
|
22
22
|
|
|
23
23
|
Subcommands:
|
|
24
24
|
init Initiate ownership change. --to <wallet> = two-party wallet transfer
|
|
25
|
-
(completed by 'accept'); --to <email> = email->org transfer (completed by 'claim')
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
(completed by 'accept'); --to <email> = email->org transfer (completed by 'claim');
|
|
26
|
+
--to-org <org_id> = same-actor move to an owned org (completes immediately).
|
|
27
|
+
preview Fetch the safe review document (pending transfer — kind-agnostic)
|
|
28
|
+
list List pending transfers (incoming default, or --outgoing) — pending rows unioned
|
|
28
29
|
accept Accept an incoming WALLET transfer (your wallet must be the to_wallet)
|
|
29
30
|
claim Claim an incoming EMAIL transfer into an org (--into <id>; omit = new org)
|
|
30
|
-
cancel Cancel a pending transfer of
|
|
31
|
+
cancel Cancel a pending transfer of any kind
|
|
31
32
|
|
|
32
33
|
Notes:
|
|
33
34
|
- Owner-side mutations on a project with a pending transfer return 409
|
|
34
35
|
PROJECT_HAS_PENDING_TRANSFER. Cancel the transfer or wait 72h for expiry.
|
|
35
36
|
- Phase 1A supports only billing_policy=migrate (default).
|
|
37
|
+
- --to-org is same-actor only in the first gateway release: you must own both orgs.
|
|
36
38
|
- Secret VALUES are inherited by the recipient on completion; rotation is advised.
|
|
37
39
|
- GitHub repo ownership is NOT transferred — handle that out of band.
|
|
38
40
|
`;
|
|
@@ -41,12 +43,14 @@ const SUB_HELP = {
|
|
|
41
43
|
init: `run402 transfer init — Initiate a project transfer
|
|
42
44
|
|
|
43
45
|
Usage:
|
|
44
|
-
run402 transfer init --to <wallet|email> [--project <id>] [--billing-policy migrate] [--message <text>] [--kysigned <record_id>] [--retain-collaborator developer]
|
|
46
|
+
run402 transfer init (--to <wallet|email> | --to-org <org_id>) [--project <id>] [--billing-policy migrate] [--message <text>] [--kysigned <record_id>] [--retain-collaborator developer]
|
|
45
47
|
|
|
46
48
|
Options:
|
|
47
49
|
--project <id> Project id (defaults to the active project)
|
|
48
50
|
--to <wallet|email> Recipient (required). A wallet uses the two-party rail (completed by
|
|
49
51
|
'accept'); an email uses the email->org rail (completed by 'claim').
|
|
52
|
+
--to-org <org_id> Destination org you already own. Same-actor only in the first gateway
|
|
53
|
+
release; completes immediately and returns project keys.
|
|
50
54
|
--billing-policy <p> Billing policy (wallet rail). Phase 1A only allows 'migrate' (default).
|
|
51
55
|
--message <text> Optional note shown to the recipient in preview + emails.
|
|
52
56
|
--kysigned <record_id> Optional KySigned record id (wallet rail; Phase 1A: informational only).
|
|
@@ -57,6 +61,7 @@ Options:
|
|
|
57
61
|
Notes:
|
|
58
62
|
- Caller's wallet/session must currently own or admin the project (gateway re-checks fresh DB).
|
|
59
63
|
- Owner-side mutations on the project are frozen until accept/claim/cancel/expiry.
|
|
64
|
+
Owned-org moves complete immediately and do not create a pending window.
|
|
60
65
|
- The project lease stays with your organization; it is NOT refunded.
|
|
61
66
|
`,
|
|
62
67
|
preview: `run402 transfer preview — Fetch the preview document
|
|
@@ -66,7 +71,7 @@ Usage:
|
|
|
66
71
|
|
|
67
72
|
Returns project name, custom domains, subdomains, function names, secret NAMES
|
|
68
73
|
(values are never returned), CI bindings that will be revoked on completion, and
|
|
69
|
-
billing implications. Works for
|
|
74
|
+
billing implications. Works for pending wallet/email/future-org transfers; any
|
|
70
75
|
party to the transfer may preview.
|
|
71
76
|
`,
|
|
72
77
|
list: `run402 transfer list — List pending transfers
|
|
@@ -74,8 +79,7 @@ party to the transfer may preview.
|
|
|
74
79
|
Usage:
|
|
75
80
|
run402 transfer list [--incoming | --outgoing] [--limit N] [--after <cursor>]
|
|
76
81
|
|
|
77
|
-
Lists
|
|
78
|
-
recipient_kind.
|
|
82
|
+
Lists pending transfers, unioned; each row carries recipient_kind.
|
|
79
83
|
|
|
80
84
|
Options:
|
|
81
85
|
--incoming List transfers OFFERED TO you (default).
|
|
@@ -99,7 +103,7 @@ via 'claim', not 'accept'.)
|
|
|
99
103
|
Usage:
|
|
100
104
|
run402 transfer cancel <transfer_id> [--reason <text>]
|
|
101
105
|
|
|
102
|
-
Cancels a pending transfer of
|
|
106
|
+
Cancels a pending transfer of any kind. You must be authorized for the row's
|
|
103
107
|
kind (a wallet signing party, or an owner/admin of the offering org / the
|
|
104
108
|
addressed-email principal). Already-processed transfers return 409
|
|
105
109
|
TRANSFER_ALREADY_PROCESSED.
|
|
@@ -124,15 +128,19 @@ const RETAIN_ROLES = new Set(["developer"]);
|
|
|
124
128
|
|
|
125
129
|
async function init(args) {
|
|
126
130
|
const parsedArgs = normalizeArgv(args);
|
|
127
|
-
const valueFlags = ["--project", "--to", "--billing-policy", "--message", "--kysigned", "--retain-collaborator"];
|
|
131
|
+
const valueFlags = ["--project", "--to", "--to-org", "--billing-policy", "--message", "--kysigned", "--retain-collaborator"];
|
|
128
132
|
assertKnownFlags(parsedArgs, [...valueFlags, "--help", "-h"], valueFlags);
|
|
129
133
|
const extra = positionalArgs(parsedArgs, valueFlags);
|
|
130
134
|
if (extra.length > 0) {
|
|
131
135
|
fail({ code: "BAD_USAGE", message: `Unexpected argument for transfer init: ${extra[0]}` });
|
|
132
136
|
}
|
|
133
137
|
const to = flagValue(parsedArgs, "--to");
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
const toOrg = flagValue(parsedArgs, "--to-org");
|
|
139
|
+
if (!to && !toOrg) {
|
|
140
|
+
fail({ code: "BAD_USAGE", message: "Missing recipient. Pass --to <wallet|email> or --to-org <org_id>." });
|
|
141
|
+
}
|
|
142
|
+
if (to && toOrg) {
|
|
143
|
+
fail({ code: "BAD_USAGE", message: "Pass exactly one recipient flag: --to <wallet|email> or --to-org <org_id>." });
|
|
136
144
|
}
|
|
137
145
|
const projectFlag = flagValue(parsedArgs, "--project");
|
|
138
146
|
const projectId = await resolveProjectId(projectFlag);
|
|
@@ -151,18 +159,17 @@ async function init(args) {
|
|
|
151
159
|
const kysigned = flagValue(parsedArgs, "--kysigned");
|
|
152
160
|
const retainCollaborator = flagValue(parsedArgs, "--retain-collaborator");
|
|
153
161
|
|
|
154
|
-
// One noun,
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
const isEmail = to.includes("@");
|
|
162
|
+
// One noun, three recipient shapes. --to keeps wallet/email auto-detection;
|
|
163
|
+
// --to-org is explicit because org ids are not human-recipient addresses.
|
|
164
|
+
const recipientKind = toOrg ? "org" : (to.includes("@") ? "email" : "wallet");
|
|
158
165
|
|
|
159
166
|
// --retain-collaborator (v1.91) is an email-only opt-in: the sender keeps a
|
|
160
167
|
// developer membership in the recipient's org (recipient must accept at claim).
|
|
161
168
|
if (retainCollaborator !== null) {
|
|
162
|
-
if (
|
|
169
|
+
if (recipientKind !== "email") {
|
|
163
170
|
fail({
|
|
164
171
|
code: "BAD_FLAG",
|
|
165
|
-
message: "--retain-collaborator applies only to email recipients
|
|
172
|
+
message: "--retain-collaborator applies only to email recipients.",
|
|
166
173
|
details: { flag: "--retain-collaborator" },
|
|
167
174
|
});
|
|
168
175
|
}
|
|
@@ -174,25 +181,48 @@ async function init(args) {
|
|
|
174
181
|
});
|
|
175
182
|
}
|
|
176
183
|
}
|
|
184
|
+
if (kysigned !== null && recipientKind !== "wallet") {
|
|
185
|
+
fail({
|
|
186
|
+
code: "BAD_FLAG",
|
|
187
|
+
message: "--kysigned applies only to wallet recipients; email and owned-org transfers do not use the KySigned rail.",
|
|
188
|
+
details: { flag: "--kysigned" },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (billingPolicy !== null && recipientKind !== "wallet") {
|
|
192
|
+
fail({
|
|
193
|
+
code: "BAD_FLAG",
|
|
194
|
+
message: "--billing-policy applies only to wallet recipients; email and owned-org transfers always migrate ownership.",
|
|
195
|
+
details: { flag: "--billing-policy" },
|
|
196
|
+
});
|
|
197
|
+
}
|
|
177
198
|
|
|
178
|
-
//
|
|
199
|
+
// All recipient shapes initiate on the unified transfer endpoint — sign that path.
|
|
179
200
|
allowanceAuthHeaders(`/projects/v1/${projectId}/transfers`);
|
|
180
201
|
|
|
181
202
|
try {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
203
|
+
let res;
|
|
204
|
+
if (recipientKind === "org") {
|
|
205
|
+
res = await getSdk().admin.transfers.initiate({
|
|
206
|
+
projectId,
|
|
207
|
+
toOrgId: toOrg,
|
|
208
|
+
message: message ?? undefined,
|
|
209
|
+
});
|
|
210
|
+
} else if (recipientKind === "email") {
|
|
211
|
+
res = await getSdk().admin.transfers.initiate({
|
|
212
|
+
projectId,
|
|
213
|
+
toEmail: to,
|
|
214
|
+
message: message ?? undefined,
|
|
215
|
+
retainCollaborator: retainCollaborator ? { role: retainCollaborator } : undefined,
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
res = await getSdk().admin.transfers.initiate({
|
|
219
|
+
projectId,
|
|
220
|
+
toWallet: to,
|
|
221
|
+
billingPolicy: billingPolicy ?? undefined,
|
|
222
|
+
message: message ?? undefined,
|
|
223
|
+
kysignedRecordId: kysigned ?? undefined,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
196
226
|
console.log(JSON.stringify(res, null, 2));
|
|
197
227
|
} catch (err) {
|
|
198
228
|
reportSdkError(err);
|
|
@@ -207,7 +237,7 @@ async function preview(args) {
|
|
|
207
237
|
fail({ code: "BAD_USAGE", message: "Usage: run402 transfer preview <transfer_id>" });
|
|
208
238
|
}
|
|
209
239
|
const transferId = positionals[0];
|
|
210
|
-
// Preview is kind-agnostic — one route serves wallet and
|
|
240
|
+
// Preview is kind-agnostic — one route serves wallet, email, and future org transfers.
|
|
211
241
|
allowanceAuthHeaders(`/agent/v1/transfers/${transferId}`);
|
|
212
242
|
|
|
213
243
|
try {
|
|
@@ -241,8 +271,8 @@ async function list(args) {
|
|
|
241
271
|
? undefined
|
|
242
272
|
: parseIntegerFlag("--limit", limitFlag, { min: 1, max: 1000 });
|
|
243
273
|
|
|
244
|
-
// Incoming/outgoing are kind-agnostic — each returns the union of
|
|
245
|
-
// email-
|
|
274
|
+
// Incoming/outgoing are kind-agnostic — each returns the union of pending
|
|
275
|
+
// wallet/email/future-org rows, tagged with recipient_kind.
|
|
246
276
|
allowanceAuthHeaders(`/agent/v1/transfers/${direction}`);
|
|
247
277
|
|
|
248
278
|
try {
|
package/package.json
CHANGED
|
@@ -218,9 +218,9 @@ export interface OperatorStatusResult {
|
|
|
218
218
|
export declare class Admin {
|
|
219
219
|
private readonly client;
|
|
220
220
|
/**
|
|
221
|
-
* Project transfer sub-namespace
|
|
222
|
-
* project
|
|
223
|
-
* accept, cancel, listIncoming, listOutgoing}`.
|
|
221
|
+
* Project transfer sub-namespace — unified wallet, email, and owned-org
|
|
222
|
+
* project transfer surface. Access via `r.admin.transfers.{initiate,
|
|
223
|
+
* preview, accept, claim, cancel, listIncoming, listOutgoing}`.
|
|
224
224
|
*/
|
|
225
225
|
readonly transfers: Transfers;
|
|
226
226
|
constructor(client: Client);
|
|
@@ -11,9 +11,9 @@ const FINANCE_WINDOWS = new Set(["24h", "7d", "30d", "90d"]);
|
|
|
11
11
|
export class Admin {
|
|
12
12
|
client;
|
|
13
13
|
/**
|
|
14
|
-
* Project transfer sub-namespace
|
|
15
|
-
* project
|
|
16
|
-
* accept, cancel, listIncoming, listOutgoing}`.
|
|
14
|
+
* Project transfer sub-namespace — unified wallet, email, and owned-org
|
|
15
|
+
* project transfer surface. Access via `r.admin.transfers.{initiate,
|
|
16
|
+
* preview, accept, claim, cancel, listIncoming, listOutgoing}`.
|
|
17
17
|
*/
|
|
18
18
|
transfers;
|
|
19
19
|
constructor(client) {
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `transfers` namespace — the unified project-transfer noun (v1.93
|
|
2
|
+
* `transfers` namespace — the unified project-transfer noun (v1.93+;
|
|
3
|
+
* owned-org recipient shape v1.96+).
|
|
3
4
|
*
|
|
4
5
|
* Exposed as `r.admin.transfers.*`. Project transfer is ONE capability,
|
|
5
6
|
* body-discriminated by recipient kind: a wallet recipient (`toWallet`, SIWX
|
|
6
|
-
* bilateral signing)
|
|
7
|
-
*
|
|
8
|
-
* `/
|
|
7
|
+
* bilateral signing), an email recipient (`toEmail`, the recipient claims into
|
|
8
|
+
* an org), or an owned org recipient (`toOrgId`, same-actor org move). All ride
|
|
9
|
+
* the same `/transfers` surface — there is no separate `/handoffs` noun (the
|
|
10
|
+
* gateway removed it in `unify-project-transfer-surface`).
|
|
9
11
|
*
|
|
10
12
|
* Gateway endpoints:
|
|
11
|
-
* POST /projects/v1/:project_id/transfers — initiate; body { to_wallet } XOR { to_email }
|
|
12
|
-
* GET /agent/v1/transfers/incoming — inbox (
|
|
13
|
-
* GET /agent/v1/transfers/outgoing — outbox (
|
|
13
|
+
* POST /projects/v1/:project_id/transfers — initiate; body { to_wallet } XOR { to_email } XOR { to_org_id }
|
|
14
|
+
* GET /agent/v1/transfers/incoming — inbox (pending kinds, unioned)
|
|
15
|
+
* GET /agent/v1/transfers/outgoing — outbox (pending kinds, unioned)
|
|
14
16
|
* GET /agent/v1/transfers/:transfer_id — preview (kind-agnostic)
|
|
15
17
|
* POST /agent/v1/transfers/:transfer_id/accept — WALLET completion (recipient SIWX-signs)
|
|
16
18
|
* POST /agent/v1/transfers/:transfer_id/claim — EMAIL completion (recipient claims into an org)
|
|
@@ -29,7 +31,7 @@ export type TransferBillingPolicy = "migrate";
|
|
|
29
31
|
export type TransferStatus = "pending" | "accepted" | "cancelled" | "expired";
|
|
30
32
|
export type TransferCancelledBy = "from_wallet" | "to_wallet" | "system";
|
|
31
33
|
/** Which kind of recipient a transfer row is addressed to. */
|
|
32
|
-
export type RecipientKind = "wallet" | "email";
|
|
34
|
+
export type RecipientKind = "wallet" | "email" | "org";
|
|
33
35
|
/** Initiate a transfer addressed to a wallet (two-party SIWX completion via `accept`). */
|
|
34
36
|
export interface InitiateWalletTransferInput {
|
|
35
37
|
/** Project id to transfer. Caller must currently own/admin it (gateway re-checks against fresh DB, not cache). */
|
|
@@ -38,6 +40,8 @@ export interface InitiateWalletTransferInput {
|
|
|
38
40
|
toWallet: string;
|
|
39
41
|
/** Mutually exclusive with {@link InitiateWalletTransferInput.toWallet}; not allowed on the wallet path. */
|
|
40
42
|
toEmail?: never;
|
|
43
|
+
/** Mutually exclusive with {@link InitiateWalletTransferInput.toWallet}; not allowed on the wallet path. */
|
|
44
|
+
toOrgId?: never;
|
|
41
45
|
/**
|
|
42
46
|
* Billing policy. Defaults to `"migrate"`. Phase 1A only supports
|
|
43
47
|
* `"migrate"`; future phases may add `"inherit"` as a separate spec.
|
|
@@ -58,6 +62,8 @@ export interface InitiateEmailTransferInput {
|
|
|
58
62
|
toEmail: string;
|
|
59
63
|
/** Mutually exclusive with {@link InitiateEmailTransferInput.toEmail}; not allowed on the email path. */
|
|
60
64
|
toWallet?: never;
|
|
65
|
+
/** Mutually exclusive with {@link InitiateEmailTransferInput.toEmail}; not allowed on the email path. */
|
|
66
|
+
toOrgId?: never;
|
|
61
67
|
/** Optional note shown to the recipient (HTML-escaped server-side). */
|
|
62
68
|
message?: string;
|
|
63
69
|
/**
|
|
@@ -76,8 +82,30 @@ export interface InitiateEmailTransferInput {
|
|
|
76
82
|
/** KySigned record id is wallet-path only; not allowed on the email path. */
|
|
77
83
|
kysignedRecordId?: never;
|
|
78
84
|
}
|
|
79
|
-
/**
|
|
80
|
-
export
|
|
85
|
+
/** Initiate an immediate move to an organization the caller already owns. */
|
|
86
|
+
export interface InitiateOrgTransferInput {
|
|
87
|
+
/** Project id to transfer. Caller must be an active owner of the source org. */
|
|
88
|
+
projectId: string;
|
|
89
|
+
/**
|
|
90
|
+
* Destination organization id. The first gateway release is same-actor only:
|
|
91
|
+
* caller must be an active owner of both source and destination orgs.
|
|
92
|
+
*/
|
|
93
|
+
toOrgId: string;
|
|
94
|
+
/** Mutually exclusive with {@link InitiateOrgTransferInput.toOrgId}; not allowed on the org path. */
|
|
95
|
+
toWallet?: never;
|
|
96
|
+
/** Mutually exclusive with {@link InitiateOrgTransferInput.toOrgId}; not allowed on the org path. */
|
|
97
|
+
toEmail?: never;
|
|
98
|
+
/** Optional free-text note recorded with the transfer audit row. */
|
|
99
|
+
message?: string;
|
|
100
|
+
/** Billing policy is wallet-path only; not allowed on the org path. */
|
|
101
|
+
billingPolicy?: never;
|
|
102
|
+
/** KySigned record id is wallet-path only; not allowed on the org path. */
|
|
103
|
+
kysignedRecordId?: never;
|
|
104
|
+
/** Retention is an email-only opt-in; not allowed on the org path. */
|
|
105
|
+
retainCollaborator?: never;
|
|
106
|
+
}
|
|
107
|
+
/** Inputs to `r.admin.transfers.initiate(...)` — wallet XOR email XOR org. */
|
|
108
|
+
export type InitiateTransferInput = InitiateWalletTransferInput | InitiateEmailTransferInput | InitiateOrgTransferInput;
|
|
81
109
|
/** Result of a wallet-addressed `initiate`. */
|
|
82
110
|
export interface InitiateTransferResult {
|
|
83
111
|
transfer_id: string;
|
|
@@ -100,6 +128,29 @@ export interface InitiateEmailTransferResult {
|
|
|
100
128
|
to_email: string;
|
|
101
129
|
expires_at: string;
|
|
102
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Result of an owned-org `initiate`. Same-actor org moves complete
|
|
133
|
+
* synchronously in the first gateway release and return project keys so the
|
|
134
|
+
* caller can continue operating the project without a follow-up fetch.
|
|
135
|
+
*/
|
|
136
|
+
export interface InitiateOrgTransferResult {
|
|
137
|
+
status: "accepted";
|
|
138
|
+
project_id: string;
|
|
139
|
+
to_organization_id: string;
|
|
140
|
+
/** Echo of the requested org id when a gateway chooses the shorter wire key. */
|
|
141
|
+
to_org_id?: string;
|
|
142
|
+
/** Present when the gateway materializes an audit transfer row. */
|
|
143
|
+
transfer_id?: string;
|
|
144
|
+
/** Present when the gateway returns the completion timestamp inline. */
|
|
145
|
+
completed_at?: string;
|
|
146
|
+
anon_key: string;
|
|
147
|
+
service_key: string;
|
|
148
|
+
secrets_rotation_advised?: true;
|
|
149
|
+
secret_names_inherited?: string[];
|
|
150
|
+
secrets_count_inherited?: number;
|
|
151
|
+
github_repo_note?: string;
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
}
|
|
103
154
|
export interface AcceptTransferResult {
|
|
104
155
|
project_id: string;
|
|
105
156
|
from_wallet: string;
|
|
@@ -126,9 +177,10 @@ export interface CancelTransferResult {
|
|
|
126
177
|
}
|
|
127
178
|
/**
|
|
128
179
|
* Summary row used in `/agent/v1/transfers/incoming` and `/outgoing`. The list
|
|
129
|
-
* is kind-agnostic: `recipient_kind` discriminates wallet
|
|
130
|
-
* rows carry `from_wallet`/`to_wallet`; email rows carry
|
|
131
|
-
* `from_organization_id
|
|
180
|
+
* is kind-agnostic: `recipient_kind` discriminates wallet, email, and future
|
|
181
|
+
* org rows. Wallet rows carry `from_wallet`/`to_wallet`; email rows carry
|
|
182
|
+
* `to_email` + `from_organization_id`; future org rows carry `to_org_id` /
|
|
183
|
+
* `to_organization_id`.
|
|
132
184
|
*/
|
|
133
185
|
export interface TransferSummary {
|
|
134
186
|
transfer_id: string;
|
|
@@ -152,6 +204,10 @@ export interface TransferSummary {
|
|
|
152
204
|
to_email?: string;
|
|
153
205
|
/** Email rows only. */
|
|
154
206
|
from_organization_id?: string | null;
|
|
207
|
+
/** Org rows only (future non-same-actor org transfers). */
|
|
208
|
+
to_org_id?: string;
|
|
209
|
+
/** Org rows only (canonical gateway field when present). */
|
|
210
|
+
to_organization_id?: string;
|
|
155
211
|
}
|
|
156
212
|
export interface ListTransfersOptions {
|
|
157
213
|
/** Page size; defaults to 50 on the gateway. */
|
|
@@ -220,7 +276,8 @@ export interface RetainCollaboratorPreview {
|
|
|
220
276
|
}
|
|
221
277
|
/**
|
|
222
278
|
* Kind-agnostic preview document. Wallet-identity fields are `null` on email
|
|
223
|
-
* rows; `to_email` and `retain_collaborator` are populated on email
|
|
279
|
+
* and org rows; `to_email` and `retain_collaborator` are populated on email
|
|
280
|
+
* rows, while org rows carry `to_org_id` / `to_organization_id` when returned.
|
|
224
281
|
*/
|
|
225
282
|
export interface ProjectTransferPreview {
|
|
226
283
|
transfer_id: string;
|
|
@@ -234,6 +291,10 @@ export interface ProjectTransferPreview {
|
|
|
234
291
|
to_wallet_display: string | null;
|
|
235
292
|
/** Email rows only. */
|
|
236
293
|
to_email?: string;
|
|
294
|
+
/** Org rows only (future non-same-actor org transfers). */
|
|
295
|
+
to_org_id?: string;
|
|
296
|
+
/** Org rows only (canonical gateway field when present). */
|
|
297
|
+
to_organization_id?: string;
|
|
237
298
|
billing_policy: TransferBillingPolicy;
|
|
238
299
|
message: string | null;
|
|
239
300
|
initiated_at: string;
|
|
@@ -290,14 +351,16 @@ export declare class Transfers {
|
|
|
290
351
|
private readonly client;
|
|
291
352
|
constructor(client: Client);
|
|
292
353
|
/**
|
|
293
|
-
* Initiate a project transfer — addressed to a wallet (`toWallet`)
|
|
294
|
-
* (`toEmail`), exactly one. Caller must
|
|
295
|
-
* (gateway re-reads owner from DB, not cache).
|
|
296
|
-
*
|
|
297
|
-
*
|
|
354
|
+
* Initiate a project transfer — addressed to a wallet (`toWallet`), an email
|
|
355
|
+
* (`toEmail`), OR an owned org (`toOrgId`), exactly one. Caller must
|
|
356
|
+
* currently own/admin `projectId` (gateway re-reads owner from DB, not cache).
|
|
357
|
+
* Wallet/email recipients create a `pending` row with a 72h expiry and freeze
|
|
358
|
+
* owner-side mutations until accepted/claimed/cancelled/expired. The first
|
|
359
|
+
* org-recipient gateway release is same-actor only and completes immediately.
|
|
298
360
|
*/
|
|
299
361
|
initiate(input: InitiateWalletTransferInput): Promise<InitiateTransferResult>;
|
|
300
362
|
initiate(input: InitiateEmailTransferInput): Promise<InitiateEmailTransferResult>;
|
|
363
|
+
initiate(input: InitiateOrgTransferInput): Promise<InitiateOrgTransferResult>;
|
|
301
364
|
/**
|
|
302
365
|
* Fetch the preview document for a pending or terminal transfer of either
|
|
303
366
|
* kind. The caller must be a party to it (wallet signer, addressed-email
|
|
@@ -326,15 +389,15 @@ export declare class Transfers {
|
|
|
326
389
|
*/
|
|
327
390
|
claim(transferId: string, opts?: ClaimTransferInput): Promise<ClaimTransferResult>;
|
|
328
391
|
/**
|
|
329
|
-
* Cancel a pending transfer of
|
|
392
|
+
* Cancel a pending transfer of any kind. The caller must be authorized for
|
|
330
393
|
* the row's kind (a wallet signer, or an owner/admin of the offering org /
|
|
331
394
|
* the addressed-email principal). Already-processed transfers return 409
|
|
332
395
|
* `TRANSFER_ALREADY_PROCESSED`.
|
|
333
396
|
*/
|
|
334
397
|
cancel(transferId: string, reason?: string): Promise<CancelTransferResult>;
|
|
335
|
-
/** Pending transfers OFFERED TO the caller —
|
|
398
|
+
/** Pending transfers OFFERED TO the caller — wallet/email/future org rows, unioned. */
|
|
336
399
|
listIncoming(opts?: ListTransfersOptions): Promise<ListTransfersResult>;
|
|
337
|
-
/** Pending transfers INITIATED BY the caller —
|
|
400
|
+
/** Pending transfers INITIATED BY the caller — wallet/email/future org rows, unioned. */
|
|
338
401
|
listOutgoing(opts?: ListTransfersOptions): Promise<ListTransfersResult>;
|
|
339
402
|
}
|
|
340
403
|
//# sourceMappingURL=transfers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../../src/namespaces/transfers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transfers.d.ts","sourceRoot":"","sources":["../../src/namespaces/transfers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,iIAAiI;AACjI,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEzE,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvD,0FAA0F;AAC1F,MAAM,WAAW,2BAA2B;IAC1C,kHAAkH;IAClH,SAAS,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,QAAQ,EAAE,MAAM,CAAC;IACjB,4GAA4G;IAC5G,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,4GAA4G;IAC5G,OAAO,CAAC,EAA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BAAyB,CAAC;IA2DnF;;;;;;;OAOG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAOlE;;;;;OAKG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa/D;;;;;;;;;OASG;IACG,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAc5F;;;;;OAKG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAahF,uFAAuF;IACjF,YAAY,CAAC,IAAI,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQjF,yFAAyF;IACnF,YAAY,CAAC,IAAI,GAAE,oBAAyB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAOlF"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `transfers` namespace — the unified project-transfer noun (v1.93
|
|
2
|
+
* `transfers` namespace — the unified project-transfer noun (v1.93+;
|
|
3
|
+
* owned-org recipient shape v1.96+).
|
|
3
4
|
*
|
|
4
5
|
* Exposed as `r.admin.transfers.*`. Project transfer is ONE capability,
|
|
5
6
|
* body-discriminated by recipient kind: a wallet recipient (`toWallet`, SIWX
|
|
6
|
-
* bilateral signing)
|
|
7
|
-
*
|
|
8
|
-
* `/
|
|
7
|
+
* bilateral signing), an email recipient (`toEmail`, the recipient claims into
|
|
8
|
+
* an org), or an owned org recipient (`toOrgId`, same-actor org move). All ride
|
|
9
|
+
* the same `/transfers` surface — there is no separate `/handoffs` noun (the
|
|
10
|
+
* gateway removed it in `unify-project-transfer-surface`).
|
|
9
11
|
*
|
|
10
12
|
* Gateway endpoints:
|
|
11
|
-
* POST /projects/v1/:project_id/transfers — initiate; body { to_wallet } XOR { to_email }
|
|
12
|
-
* GET /agent/v1/transfers/incoming — inbox (
|
|
13
|
-
* GET /agent/v1/transfers/outgoing — outbox (
|
|
13
|
+
* POST /projects/v1/:project_id/transfers — initiate; body { to_wallet } XOR { to_email } XOR { to_org_id }
|
|
14
|
+
* GET /agent/v1/transfers/incoming — inbox (pending kinds, unioned)
|
|
15
|
+
* GET /agent/v1/transfers/outgoing — outbox (pending kinds, unioned)
|
|
14
16
|
* GET /agent/v1/transfers/:transfer_id — preview (kind-agnostic)
|
|
15
17
|
* POST /agent/v1/transfers/:transfer_id/accept — WALLET completion (recipient SIWX-signs)
|
|
16
18
|
* POST /agent/v1/transfers/:transfer_id/claim — EMAIL completion (recipient claims into an org)
|
|
@@ -33,13 +35,33 @@ export class Transfers {
|
|
|
33
35
|
async initiate(input) {
|
|
34
36
|
const toWallet = "toWallet" in input ? input.toWallet : undefined;
|
|
35
37
|
const toEmail = "toEmail" in input ? input.toEmail : undefined;
|
|
38
|
+
const toOrgId = "toOrgId" in input ? input.toOrgId : undefined;
|
|
36
39
|
const hasWallet = typeof toWallet === "string" && toWallet.length > 0;
|
|
37
40
|
const hasEmail = typeof toEmail === "string" && toEmail.length > 0;
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const hasOrg = typeof toOrgId === "string" && toOrgId.length > 0;
|
|
42
|
+
const recipientCount = Number(hasWallet) + Number(hasEmail) + Number(hasOrg);
|
|
43
|
+
if (recipientCount !== 1) {
|
|
44
|
+
throw new LocalError("Provide exactly one of toWallet, toEmail, or toOrgId.", "initiating project transfer", { code: "VALIDATION_ERROR", details: { fields: ["toWallet", "toEmail", "toOrgId"] } });
|
|
40
45
|
}
|
|
41
46
|
const path = `/projects/v1/${encodeURIComponent(input.projectId)}/transfers`;
|
|
47
|
+
if (hasOrg) {
|
|
48
|
+
rejectDefinedField(input, "billingPolicy", "org");
|
|
49
|
+
rejectDefinedField(input, "kysignedRecordId", "org");
|
|
50
|
+
rejectDefinedField(input, "retainCollaborator", "org");
|
|
51
|
+
const body = { to_org_id: toOrgId };
|
|
52
|
+
if (input.message !== undefined)
|
|
53
|
+
body.message = input.message;
|
|
54
|
+
const result = await this.client.request(path, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
body,
|
|
57
|
+
context: "initiating project transfer",
|
|
58
|
+
});
|
|
59
|
+
await persistProjectKeys(this.client, result);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
42
62
|
if (hasEmail) {
|
|
63
|
+
rejectDefinedField(input, "billingPolicy", "email");
|
|
64
|
+
rejectDefinedField(input, "kysignedRecordId", "email");
|
|
43
65
|
const body = { to_email: toEmail };
|
|
44
66
|
if (input.message !== undefined)
|
|
45
67
|
body.message = input.message;
|
|
@@ -53,6 +75,7 @@ export class Transfers {
|
|
|
53
75
|
});
|
|
54
76
|
}
|
|
55
77
|
const w = input;
|
|
78
|
+
rejectDefinedField(w, "retainCollaborator", "wallet");
|
|
56
79
|
const body = { to_wallet: toWallet };
|
|
57
80
|
if (w.billingPolicy !== undefined)
|
|
58
81
|
body.billing_policy = w.billingPolicy;
|
|
@@ -89,20 +112,7 @@ export class Transfers {
|
|
|
89
112
|
body: {},
|
|
90
113
|
context: "accepting project transfer",
|
|
91
114
|
});
|
|
92
|
-
|
|
93
|
-
// project immediately, mirroring `projects.provision`.
|
|
94
|
-
if (result.anon_key && result.service_key) {
|
|
95
|
-
const creds = this.client.credentials;
|
|
96
|
-
if (creds.saveProject) {
|
|
97
|
-
await creds.saveProject(result.project_id, {
|
|
98
|
-
anon_key: result.anon_key,
|
|
99
|
-
service_key: result.service_key,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
if (creds.setActiveProject) {
|
|
103
|
-
await creds.setActiveProject(result.project_id);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
115
|
+
await persistProjectKeys(this.client, result);
|
|
106
116
|
return result;
|
|
107
117
|
}
|
|
108
118
|
/**
|
|
@@ -123,25 +133,11 @@ export class Transfers {
|
|
|
123
133
|
body.accept_retained_collaborator = opts.acceptRetainedCollaborator;
|
|
124
134
|
}
|
|
125
135
|
const result = await this.client.request(`/agent/v1/transfers/${encodeURIComponent(transferId)}/claim`, { method: "POST", body, context: "claiming project transfer" });
|
|
126
|
-
|
|
127
|
-
// immediately, mirroring `accept`. Keys are returned only after the
|
|
128
|
-
// ownership flip commits, to the authorized claimant.
|
|
129
|
-
if (result.anon_key && result.service_key) {
|
|
130
|
-
const creds = this.client.credentials;
|
|
131
|
-
if (creds.saveProject) {
|
|
132
|
-
await creds.saveProject(result.project_id, {
|
|
133
|
-
anon_key: result.anon_key,
|
|
134
|
-
service_key: result.service_key,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (creds.setActiveProject) {
|
|
138
|
-
await creds.setActiveProject(result.project_id);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
136
|
+
await persistProjectKeys(this.client, result);
|
|
141
137
|
return result;
|
|
142
138
|
}
|
|
143
139
|
/**
|
|
144
|
-
* Cancel a pending transfer of
|
|
140
|
+
* Cancel a pending transfer of any kind. The caller must be authorized for
|
|
145
141
|
* the row's kind (a wallet signer, or an owner/admin of the offering org /
|
|
146
142
|
* the addressed-email principal). Already-processed transfers return 409
|
|
147
143
|
* `TRANSFER_ALREADY_PROCESSED`.
|
|
@@ -156,7 +152,7 @@ export class Transfers {
|
|
|
156
152
|
context: "cancelling project transfer",
|
|
157
153
|
});
|
|
158
154
|
}
|
|
159
|
-
/** Pending transfers OFFERED TO the caller —
|
|
155
|
+
/** Pending transfers OFFERED TO the caller — wallet/email/future org rows, unioned. */
|
|
160
156
|
async listIncoming(opts = {}) {
|
|
161
157
|
const q = buildPagination(opts);
|
|
162
158
|
const path = q ? `/agent/v1/transfers/incoming?${q}` : "/agent/v1/transfers/incoming";
|
|
@@ -164,7 +160,7 @@ export class Transfers {
|
|
|
164
160
|
context: "listing incoming transfers",
|
|
165
161
|
});
|
|
166
162
|
}
|
|
167
|
-
/** Pending transfers INITIATED BY the caller —
|
|
163
|
+
/** Pending transfers INITIATED BY the caller — wallet/email/future org rows, unioned. */
|
|
168
164
|
async listOutgoing(opts = {}) {
|
|
169
165
|
const q = buildPagination(opts);
|
|
170
166
|
const path = q ? `/agent/v1/transfers/outgoing?${q}` : "/agent/v1/transfers/outgoing";
|
|
@@ -173,6 +169,25 @@ export class Transfers {
|
|
|
173
169
|
});
|
|
174
170
|
}
|
|
175
171
|
}
|
|
172
|
+
async function persistProjectKeys(client, result) {
|
|
173
|
+
if (result.project_id && result.anon_key && result.service_key) {
|
|
174
|
+
const creds = client.credentials;
|
|
175
|
+
if (creds.saveProject) {
|
|
176
|
+
await creds.saveProject(result.project_id, {
|
|
177
|
+
anon_key: result.anon_key,
|
|
178
|
+
service_key: result.service_key,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (creds.setActiveProject) {
|
|
182
|
+
await creds.setActiveProject(result.project_id);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function rejectDefinedField(input, field, recipient) {
|
|
187
|
+
if (input[field] !== undefined) {
|
|
188
|
+
throw new LocalError(`${field} is not supported for ${recipient}-addressed project transfers.`, "initiating project transfer", { code: "VALIDATION_ERROR", details: { field, recipient } });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
176
191
|
function buildPagination(opts) {
|
|
177
192
|
const parts = [];
|
|
178
193
|
if (opts.limit !== undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.js","sourceRoot":"","sources":["../../src/namespaces/transfers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transfers.js","sourceRoot":"","sources":["../../src/namespaces/transfers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAqW1C,gFAAgF;AAEhF,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC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