@invonetwork/web-sdk 3.29.0 → 3.30.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 +1432 -1389
- package/README.md +2954 -2923
- package/dist/{chunk-FJR44FKW.js → chunk-664RAO2T.js} +25 -5
- package/dist/chunk-BIK6UXY7.js +6 -0
- package/dist/chunk-QDHOPJFL.js +1634 -0
- package/dist/{chunk-VP3OK4J4.js → chunk-TSTP2CWA.js} +471 -3
- package/dist/game-server.cjs +295 -15
- package/dist/game-server.d.cts +49 -9
- package/dist/game-server.d.ts +49 -9
- package/dist/game-server.js +278 -20
- package/dist/game.cjs +2680 -9
- package/dist/game.d.cts +78 -4
- package/dist/game.d.ts +78 -4
- package/dist/game.js +561 -3
- package/dist/hosted-approval-DcY4U2RN.d.cts +96 -0
- package/dist/hosted-approval-DiKmtjEh.d.ts +96 -0
- package/dist/index.d.cts +7 -96
- package/dist/index.d.ts +7 -96
- package/dist/index.js +2 -1635
- package/dist/loyalty-events-CmDw2ZoR.d.cts +40 -0
- package/dist/loyalty-events-CmDw2ZoR.d.ts +40 -0
- package/dist/{server-Dnx5jxS4.d.ts → server-B0mvlGFY.d.ts} +17 -2
- package/dist/{server-UZ38eD2p.d.cts → server-DEh9wjF2.d.cts} +17 -2
- package/dist/server.cjs +22 -1
- package/dist/server.d.cts +4 -3
- package/dist/server.d.ts +4 -3
- package/dist/server.js +3 -4
- package/dist/{types-_lIm74kd.d.ts → types-BTbZicgj.d.cts} +1 -40
- package/dist/{types-_lIm74kd.d.cts → types-BTbZicgj.d.ts} +1 -40
- package/dist/{types-CoW9LopI.d.cts → types-jUxfYjiD.d.cts} +76 -1
- package/dist/{types-CoW9LopI.d.ts → types-jUxfYjiD.d.ts} +76 -1
- package/dist/{version-xyYQO5hp.d.cts → version-DfVkILOj.d.cts} +1 -1
- package/dist/{version-xyYQO5hp.d.ts → version-DfVkILOj.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-6CN236QH.js +0 -473
- package/dist/chunk-KZJABBVT.js +0 -6
package/dist/game-server.cjs
CHANGED
|
@@ -1685,7 +1685,7 @@ function toPhoneChangeRequest(raw) {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
|
|
1687
1687
|
// src/version.ts
|
|
1688
|
-
var SDK_VERSION = "3.
|
|
1688
|
+
var SDK_VERSION = "3.30.0";
|
|
1689
1689
|
|
|
1690
1690
|
// src/payouts.ts
|
|
1691
1691
|
var AMOUNT = /^\d+(\.\d{1,2})?$/;
|
|
@@ -3753,6 +3753,27 @@ var SandboxSubscriptionsServer = class {
|
|
|
3753
3753
|
var SandboxServer = class {
|
|
3754
3754
|
constructor(http, auth, clockKey) {
|
|
3755
3755
|
this.subscriptions = new SandboxSubscriptionsServer(http, auth, clockKey);
|
|
3756
|
+
this.http = http;
|
|
3757
|
+
this.auth = auth;
|
|
3758
|
+
}
|
|
3759
|
+
/**
|
|
3760
|
+
* Public demo key only (3.30.0): approve a send or transfer the demo player started, without
|
|
3761
|
+
* a passkey. INVO's demo sandbox answers with the claim code, which the recipient's game
|
|
3762
|
+
* server then uses with `claimCurrency` (a send) or `claimTransfer` (a transfer). Refused on
|
|
3763
|
+
* every other key and in production.
|
|
3764
|
+
*/
|
|
3765
|
+
async approveDemoMove(transactionId, kind, opts) {
|
|
3766
|
+
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
3767
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
3768
|
+
}
|
|
3769
|
+
const path2 = `/test-auth/${kind === "send" ? "sends" : "transfers"}/${encodeURIComponent(transactionId)}/approve`;
|
|
3770
|
+
const raw = await this.http.post(path2, {}, this.auth, { signal: opts?.signal });
|
|
3771
|
+
return {
|
|
3772
|
+
status: String(raw["status"] ?? ""),
|
|
3773
|
+
claimCode: typeof raw["claim_code"] === "string" ? raw["claim_code"] : null,
|
|
3774
|
+
claimCodeExpiresAt: typeof raw["claim_code_expires_at"] === "string" ? raw["claim_code_expires_at"] : null,
|
|
3775
|
+
raw
|
|
3776
|
+
};
|
|
3756
3777
|
}
|
|
3757
3778
|
};
|
|
3758
3779
|
var InvoServer = class {
|
|
@@ -5334,17 +5355,26 @@ function writeFile(file, data) {
|
|
|
5334
5355
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
5335
5356
|
fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n", { encoding: "utf8", mode: 384 });
|
|
5336
5357
|
}
|
|
5358
|
+
function currentReplId(override) {
|
|
5359
|
+
const v = override ?? (typeof process !== "undefined" ? process.env.REPL_ID : void 0);
|
|
5360
|
+
return v && v.trim() ? v.trim() : void 0;
|
|
5361
|
+
}
|
|
5362
|
+
function sameFork(saved, host, replId) {
|
|
5363
|
+
if (replId && saved.replId) return saved.replId === replId;
|
|
5364
|
+
return !host || !saved.host || saved.host === host;
|
|
5365
|
+
}
|
|
5337
5366
|
function loadProject(opts = {}) {
|
|
5338
5367
|
const file = opts.file ?? DEFAULT_PROJECT_FILE;
|
|
5368
|
+
const replId = currentReplId(opts.replId);
|
|
5339
5369
|
if (opts.projectId) {
|
|
5340
5370
|
if (!isValidProjectId(opts.projectId)) throw new Error('INVO_PROJECT_ID must be "proj_" + a 26-character ULID.');
|
|
5341
5371
|
const saved2 = readFile(file);
|
|
5342
|
-
return saved2 && saved2.projectId === opts.projectId ? saved2 : { projectId: opts.projectId };
|
|
5372
|
+
return saved2 && saved2.projectId === opts.projectId ? saved2 : { projectId: opts.projectId, replId };
|
|
5343
5373
|
}
|
|
5344
5374
|
const host = hostOf(opts.publicUrl);
|
|
5345
5375
|
const saved = readFile(file);
|
|
5346
|
-
if (saved && (
|
|
5347
|
-
const fresh = { projectId: newDemoProjectId(), host };
|
|
5376
|
+
if (saved && sameFork(saved, host, replId)) return replId && !saved.replId ? { ...saved, replId } : saved;
|
|
5377
|
+
const fresh = { projectId: newDemoProjectId(), host, replId };
|
|
5348
5378
|
try {
|
|
5349
5379
|
writeFile(file, fresh);
|
|
5350
5380
|
} catch {
|
|
@@ -5356,7 +5386,8 @@ async function registerProject(opts) {
|
|
|
5356
5386
|
const file = opts.file ?? DEFAULT_PROJECT_FILE;
|
|
5357
5387
|
const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
|
|
5358
5388
|
const base = (opts.baseUrl ?? SANDBOX_BASE_URL).replace(/\/+$/, "");
|
|
5359
|
-
|
|
5389
|
+
const replId = currentReplId(opts.replId);
|
|
5390
|
+
let project = loadProject({ file, publicUrl: opts.webhookUrl, projectId: opts.projectId, replId });
|
|
5360
5391
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
5361
5392
|
const res = await fetchImpl(base + "/api/demo/projects/register", {
|
|
5362
5393
|
method: "POST",
|
|
@@ -5372,7 +5403,7 @@ async function registerProject(opts) {
|
|
|
5372
5403
|
});
|
|
5373
5404
|
const body = await res.json().catch(() => ({}));
|
|
5374
5405
|
if (res.status === 409 && body.error_code === "PROJECT_REGISTERED" && attempt === 0 && !opts.projectId) {
|
|
5375
|
-
project = { projectId: newDemoProjectId(), host: hostOf(opts.webhookUrl) };
|
|
5406
|
+
project = { projectId: newDemoProjectId(), host: hostOf(opts.webhookUrl), replId };
|
|
5376
5407
|
continue;
|
|
5377
5408
|
}
|
|
5378
5409
|
if (!res.ok) throw new Error(`INVO demo registration failed (${res.status} ${body.error_code ?? ""}): ${body.error ?? ""}`.trim());
|
|
@@ -5381,12 +5412,13 @@ async function registerProject(opts) {
|
|
|
5381
5412
|
project = {
|
|
5382
5413
|
projectId: project.projectId,
|
|
5383
5414
|
host: hostOf(opts.webhookUrl),
|
|
5415
|
+
replId,
|
|
5384
5416
|
webhookUrl: opts.webhookUrl,
|
|
5385
5417
|
webhookSecret: body.webhook?.signing_secret ?? project.webhookSecret,
|
|
5386
5418
|
registrationToken: body.registration_token ?? project.registrationToken
|
|
5387
5419
|
};
|
|
5388
5420
|
} else {
|
|
5389
|
-
project = { ...project, host: project.host ??
|
|
5421
|
+
project = { ...project, host: hostOf(opts.webhookUrl) ?? project.host, replId: replId ?? project.replId, webhookUrl: opts.webhookUrl };
|
|
5390
5422
|
}
|
|
5391
5423
|
try {
|
|
5392
5424
|
writeFile(file, project);
|
|
@@ -5413,6 +5445,19 @@ var GameServerError = class extends Error {
|
|
|
5413
5445
|
this.requestId = requestId;
|
|
5414
5446
|
}
|
|
5415
5447
|
};
|
|
5448
|
+
function moveDetails(raw) {
|
|
5449
|
+
const d = (raw?.["send_details"] ?? raw?.["transfer_details"] ?? {}) || {};
|
|
5450
|
+
const pick = (...keys) => {
|
|
5451
|
+
for (const k of keys) if (d[k] !== void 0 && d[k] !== null && d[k] !== "") return String(d[k]);
|
|
5452
|
+
return null;
|
|
5453
|
+
};
|
|
5454
|
+
const toId = pick("receiving_game_id", "target_game_id");
|
|
5455
|
+
const fromId = pick("sending_game_id", "source_game_id");
|
|
5456
|
+
const toName = pick("receiving_game", "target_game", "target_game_name");
|
|
5457
|
+
const fromName = pick("sending_game", "source_game", "source_game_name");
|
|
5458
|
+
const sameGame = fromId !== null && toId !== null ? fromId === toId : toName !== null && toName === fromName;
|
|
5459
|
+
return { sameGame, destinationName: toName, currencyName: pick("currency", "currency_name") ?? (typeof raw?.["currency_name"] === "string" ? raw["currency_name"] : null) };
|
|
5460
|
+
}
|
|
5416
5461
|
function validateEconomy(economy) {
|
|
5417
5462
|
const problems = [];
|
|
5418
5463
|
if (!economy?.premium?.name) problems.push("premium.name is required");
|
|
@@ -5518,6 +5563,7 @@ function createInvoGameServer(options) {
|
|
|
5518
5563
|
maxPerMinute: economy.soft.maxEarnPerMinute ?? 1e4
|
|
5519
5564
|
};
|
|
5520
5565
|
const iso = () => now().toISOString();
|
|
5566
|
+
const environmentNow = options.environment ?? (() => options.sandbox ? "sandbox" : "production");
|
|
5521
5567
|
function toPlayer(p) {
|
|
5522
5568
|
return { id: p.id, email: p.email, name: p.name, phoneMasked: maskPhone(p.phone) };
|
|
5523
5569
|
}
|
|
@@ -5573,7 +5619,9 @@ function createInvoGameServer(options) {
|
|
|
5573
5619
|
premium: { name: economy.premium.name, packs: economy.premium.packs },
|
|
5574
5620
|
soft: { name: economy.soft.name },
|
|
5575
5621
|
items: economy.items,
|
|
5576
|
-
sandbox: options.sandbox
|
|
5622
|
+
sandbox: options.sandbox,
|
|
5623
|
+
demo: !!options.demoProjectId,
|
|
5624
|
+
playerFields: { phone: options.demoProjectId ? "hidden" : "first_sign_in" }
|
|
5577
5625
|
};
|
|
5578
5626
|
return json(200, body);
|
|
5579
5627
|
}
|
|
@@ -5903,8 +5951,225 @@ function createInvoGameServer(options) {
|
|
|
5903
5951
|
throw err;
|
|
5904
5952
|
}
|
|
5905
5953
|
}
|
|
5954
|
+
function transferStatus() {
|
|
5955
|
+
const demo = !!options.demoProjectId;
|
|
5956
|
+
const environment = environmentNow();
|
|
5957
|
+
const setting = options.transfers ?? "auto";
|
|
5958
|
+
let reason = null;
|
|
5959
|
+
if (setting === false) reason = "off";
|
|
5960
|
+
else if (setting === "auto" && !demo) {
|
|
5961
|
+
if (environment === "resolving") reason = "checking";
|
|
5962
|
+
else if (environment === "sandbox") reason = "sandbox";
|
|
5963
|
+
}
|
|
5964
|
+
return {
|
|
5965
|
+
enabled: reason === null,
|
|
5966
|
+
reason,
|
|
5967
|
+
demo,
|
|
5968
|
+
scope: demo ? "project" : "network",
|
|
5969
|
+
recipientFields: demo ? { email: "required", phone: "hidden" } : { email: "optional", phone: "required" },
|
|
5970
|
+
apiBaseUrl: reason === null ? options.playerApiBaseUrl?.() ?? null : null,
|
|
5971
|
+
approval: demo ? "sandbox" : "passkey"
|
|
5972
|
+
};
|
|
5973
|
+
}
|
|
5974
|
+
function requireTransfers() {
|
|
5975
|
+
const status = transferStatus();
|
|
5976
|
+
if (!status.enabled) {
|
|
5977
|
+
throw new GameServerError(
|
|
5978
|
+
403,
|
|
5979
|
+
"TRANSFERS_DISABLED",
|
|
5980
|
+
status.reason === "sandbox" ? "Transfers are off on this sandbox key. Set INVO_TRANSFERS=on to try them, or use your production key." : status.reason === "checking" ? "Checking this game's INVO key. Try again in a moment." : "Transfers are switched off for this game."
|
|
5981
|
+
);
|
|
5982
|
+
}
|
|
5983
|
+
return status;
|
|
5984
|
+
}
|
|
5985
|
+
async function transferToken(request) {
|
|
5986
|
+
const status = requireTransfers();
|
|
5987
|
+
const { player } = await sessionPlayer(request);
|
|
5988
|
+
try {
|
|
5989
|
+
const minted = await invo.mintPlayerToken({ playerEmail: player.email });
|
|
5990
|
+
return json(200, { token: minted.token, expiresAt: minted.expiresAt, apiBaseUrl: status.apiBaseUrl }, { "cache-control": "no-store" });
|
|
5991
|
+
} catch (err) {
|
|
5992
|
+
if (err instanceof InvoError) throw fromInvoError(err);
|
|
5993
|
+
throw err;
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
async function startTransfer(request) {
|
|
5997
|
+
requireTransfers();
|
|
5998
|
+
const { player } = await sessionPlayer(request);
|
|
5999
|
+
const body = await readJson(request);
|
|
6000
|
+
const kind = body["kind"] === "send" ? "send" : "transfer";
|
|
6001
|
+
const amount = String(body["amount"] ?? "").trim();
|
|
6002
|
+
if (!/^\d{1,9}(\.\d{1,2})?$/.test(amount) || Number(amount) <= 0) {
|
|
6003
|
+
throw new GameServerError(400, "INVALID_AMOUNT", "Enter an amount greater than zero.");
|
|
6004
|
+
}
|
|
6005
|
+
const targetGameId = body["targetGameId"];
|
|
6006
|
+
if ((typeof targetGameId !== "string" || !targetGameId.trim()) && typeof targetGameId !== "number") {
|
|
6007
|
+
throw new GameServerError(400, "INVALID_GAME", "Pick a game to send to.");
|
|
6008
|
+
}
|
|
6009
|
+
const requestId = typeof body["clientRequestId"] === "string" ? body["clientRequestId"] : "";
|
|
6010
|
+
if (requestId && !REQUEST_ID.test(requestId)) {
|
|
6011
|
+
throw new GameServerError(400, "INVALID_REQUEST_ID", "clientRequestId must be 8 to 64 letters, digits, - or _.");
|
|
6012
|
+
}
|
|
6013
|
+
const clientRequestId = requestId || crypto.randomBytes(16).toString("hex");
|
|
6014
|
+
const typedEmail = typeof body["recipientEmail"] === "string" ? body["recipientEmail"].trim().toLowerCase() : "";
|
|
6015
|
+
if (typedEmail && !EMAIL.test(typedEmail)) throw new GameServerError(400, "INVALID_EMAIL", "Check the recipient's email address.");
|
|
6016
|
+
let senderPhone;
|
|
6017
|
+
let recipientEmail;
|
|
6018
|
+
let recipientPhone;
|
|
6019
|
+
const demoPid = options.demoProjectId;
|
|
6020
|
+
if (demoPid) {
|
|
6021
|
+
if (!typedEmail) {
|
|
6022
|
+
throw new GameServerError(400, "RECIPIENT_EMAIL_REQUIRED", "Enter your friend's email: the one they sign in to this game with.");
|
|
6023
|
+
}
|
|
6024
|
+
recipientEmail = toDemoEmail(typedEmail, demoPid);
|
|
6025
|
+
if (recipientEmail === player.email) throw new GameServerError(400, "RECIPIENT_IS_SENDER", "Pick someone other than yourself.");
|
|
6026
|
+
recipientPhone = demoPhoneFor(recipientEmail);
|
|
6027
|
+
senderPhone = demoPhoneFor(player.email);
|
|
6028
|
+
} else {
|
|
6029
|
+
recipientPhone = typeof body["recipientPhone"] === "string" ? body["recipientPhone"].replace(/[\s()-]/g, "") : "";
|
|
6030
|
+
if (!E1642.test(recipientPhone)) {
|
|
6031
|
+
throw new GameServerError(400, "INVALID_PHONE", "Enter the recipient's phone in international format, e.g. +15555550111.");
|
|
6032
|
+
}
|
|
6033
|
+
recipientEmail = typedEmail || void 0;
|
|
6034
|
+
const typedSender = typeof body["senderPhone"] === "string" ? body["senderPhone"].replace(/[\s()-]/g, "") : "";
|
|
6035
|
+
senderPhone = typedSender || player.phone || "";
|
|
6036
|
+
if (!E1642.test(senderPhone)) throw new GameServerError(400, "SENDER_PHONE_REQUIRED", "Add the phone number on your INVO account to send.");
|
|
6037
|
+
}
|
|
6038
|
+
try {
|
|
6039
|
+
const started = kind === "send" ? await invo.initiateSend({
|
|
6040
|
+
clientRequestId,
|
|
6041
|
+
senderPlayerName: player.name,
|
|
6042
|
+
senderPlayerEmail: player.email,
|
|
6043
|
+
senderPlayerPhone: senderPhone,
|
|
6044
|
+
receiverPlayerPhone: recipientPhone,
|
|
6045
|
+
...recipientEmail ? { receiverPlayerEmail: recipientEmail } : {},
|
|
6046
|
+
receivingGameId: targetGameId,
|
|
6047
|
+
amount
|
|
6048
|
+
}) : await invo.initiateTransfer({
|
|
6049
|
+
clientRequestId,
|
|
6050
|
+
sourcePlayerName: player.name,
|
|
6051
|
+
sourcePlayerEmail: player.email,
|
|
6052
|
+
sourcePlayerPhone: senderPhone,
|
|
6053
|
+
targetPlayerPhone: recipientPhone,
|
|
6054
|
+
...recipientEmail ? { targetPlayerEmail: recipientEmail } : {},
|
|
6055
|
+
targetGameId,
|
|
6056
|
+
amount
|
|
6057
|
+
});
|
|
6058
|
+
log("info", "transfer started", { kind, playerId: player.id, transactionId: started.transactionId });
|
|
6059
|
+
if (demoPid && recipientEmail) {
|
|
6060
|
+
const details = moveDetails(started.raw);
|
|
6061
|
+
const move = {
|
|
6062
|
+
transactionId: started.transactionId,
|
|
6063
|
+
kind,
|
|
6064
|
+
fromPlayerId: player.id,
|
|
6065
|
+
fromName: player.name,
|
|
6066
|
+
toEmail: recipientEmail,
|
|
6067
|
+
amount,
|
|
6068
|
+
currencyName: details.currencyName ?? economy.premium.name,
|
|
6069
|
+
sameGame: details.sameGame,
|
|
6070
|
+
destinationName: details.destinationName ?? "",
|
|
6071
|
+
status: "started",
|
|
6072
|
+
claimCode: null,
|
|
6073
|
+
claimCodeExpiresAt: null,
|
|
6074
|
+
createdAt: iso()
|
|
6075
|
+
};
|
|
6076
|
+
await store.transact((s) => void ((s.demoMoves ?? (s.demoMoves = {}))[move.transactionId] = move));
|
|
6077
|
+
}
|
|
6078
|
+
const answer = {
|
|
6079
|
+
transactionId: started.transactionId,
|
|
6080
|
+
kind,
|
|
6081
|
+
guardianPending: Boolean(started.guardianApproval),
|
|
6082
|
+
playerToken: started.playerToken ?? null,
|
|
6083
|
+
approval: demoPid ? "sandbox" : "passkey"
|
|
6084
|
+
};
|
|
6085
|
+
return json(200, answer, { "cache-control": "no-store" });
|
|
6086
|
+
} catch (err) {
|
|
6087
|
+
if (err instanceof InvoError) throw fromInvoError(err);
|
|
6088
|
+
throw err;
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
function requireDemo() {
|
|
6092
|
+
requireTransfers();
|
|
6093
|
+
if (!options.demoProjectId) {
|
|
6094
|
+
throw new GameServerError(409, "PASSKEY_REQUIRED", "Approve and collect on INVO's page with your passkey.");
|
|
6095
|
+
}
|
|
6096
|
+
return options.demoProjectId;
|
|
6097
|
+
}
|
|
6098
|
+
async function approveMove(request, id) {
|
|
6099
|
+
requireDemo();
|
|
6100
|
+
const { player } = await sessionPlayer(request);
|
|
6101
|
+
const move = await store.read((s) => s.demoMoves?.[id] ?? null);
|
|
6102
|
+
if (!move || move.fromPlayerId !== player.id) throw new GameServerError(404, "TRANSFER_NOT_FOUND", "That transfer isn't yours to approve.");
|
|
6103
|
+
if (move.status !== "started") return json(200, { status: "approved", claimCode: move.claimCode, replayed: true });
|
|
6104
|
+
try {
|
|
6105
|
+
const approved = await invo.sandbox.approveDemoMove(id, move.kind);
|
|
6106
|
+
await store.transact((s) => {
|
|
6107
|
+
const m = s.demoMoves?.[id];
|
|
6108
|
+
if (m && m.status === "started") {
|
|
6109
|
+
m.status = "approved";
|
|
6110
|
+
m.claimCode = approved.claimCode;
|
|
6111
|
+
m.claimCodeExpiresAt = approved.claimCodeExpiresAt;
|
|
6112
|
+
}
|
|
6113
|
+
});
|
|
6114
|
+
log("info", "demo transfer approved", { kind: move.kind, playerId: player.id, transactionId: id });
|
|
6115
|
+
return json(200, { status: "approved", claimCode: approved.claimCode, replayed: false });
|
|
6116
|
+
} catch (err) {
|
|
6117
|
+
if (err instanceof InvoError) throw fromInvoError(err);
|
|
6118
|
+
throw err;
|
|
6119
|
+
}
|
|
6120
|
+
}
|
|
6121
|
+
async function pendingMoves(request) {
|
|
6122
|
+
requireDemo();
|
|
6123
|
+
const { player } = await sessionPlayer(request);
|
|
6124
|
+
const nowMs = now().getTime();
|
|
6125
|
+
const moves = await store.read((s) => Object.values(s.demoMoves ?? {}));
|
|
6126
|
+
const pending = moves.filter(
|
|
6127
|
+
(m) => m.toEmail === player.email && m.status === "approved" && m.sameGame && (!m.claimCodeExpiresAt || Date.parse(m.claimCodeExpiresAt) > nowMs) || m.fromPlayerId === player.id && m.status === "started"
|
|
6128
|
+
).sort((a, b) => b.createdAt.localeCompare(a.createdAt)).map((m) => {
|
|
6129
|
+
const incoming = m.toEmail === player.email;
|
|
6130
|
+
return {
|
|
6131
|
+
transferId: m.transactionId,
|
|
6132
|
+
kind: incoming ? "receiving_confirm" : "identity_gate",
|
|
6133
|
+
flow: m.kind,
|
|
6134
|
+
amount: m.amount,
|
|
6135
|
+
currency: m.currencyName,
|
|
6136
|
+
counterpartyGame: incoming ? `${m.fromName}, in this game` : m.destinationName || "another game",
|
|
6137
|
+
expiresAt: m.claimCodeExpiresAt,
|
|
6138
|
+
stepUpRequired: false,
|
|
6139
|
+
held: false,
|
|
6140
|
+
holdReason: null,
|
|
6141
|
+
raw: {}
|
|
6142
|
+
};
|
|
6143
|
+
});
|
|
6144
|
+
return json(200, { pending }, { "cache-control": "no-store" });
|
|
6145
|
+
}
|
|
6146
|
+
async function collectMove(request, id) {
|
|
6147
|
+
requireDemo();
|
|
6148
|
+
const { player } = await sessionPlayer(request);
|
|
6149
|
+
const move = await store.read((s) => s.demoMoves?.[id] ?? null);
|
|
6150
|
+
if (!move || move.toEmail !== player.email) throw new GameServerError(404, "TRANSFER_NOT_FOUND", "There's nothing to collect with that id.");
|
|
6151
|
+
if (move.status === "collected") return json(200, { status: "collected", replayed: true, wallet: await readWallet(player) });
|
|
6152
|
+
if (move.status !== "approved" || !move.claimCode) throw new GameServerError(409, "NOT_APPROVED_YET", "The sender hasn't approved this one yet.");
|
|
6153
|
+
if (!move.sameGame) throw new GameServerError(409, "OTHER_GAME", `This one is waiting in ${move.destinationName || "another game"}; collect it there.`);
|
|
6154
|
+
try {
|
|
6155
|
+
if (move.kind === "send") {
|
|
6156
|
+
await invo.claimCurrency({ claimCode: move.claimCode, receiverPlayerName: player.name, receiverPlayerEmail: player.email, receiverPlayerPhone: demoPhoneFor(player.email) });
|
|
6157
|
+
} else {
|
|
6158
|
+
throw new GameServerError(409, "OTHER_GAME", "Collect this transfer in the game it was sent to.");
|
|
6159
|
+
}
|
|
6160
|
+
} catch (err) {
|
|
6161
|
+
if (err instanceof InvoError) throw fromInvoError(err);
|
|
6162
|
+
throw err;
|
|
6163
|
+
}
|
|
6164
|
+
await store.transact((s) => {
|
|
6165
|
+
const m = s.demoMoves?.[id];
|
|
6166
|
+
if (m) m.status = "collected";
|
|
6167
|
+
});
|
|
6168
|
+
log("info", "demo transfer collected", { kind: move.kind, playerId: player.id, transactionId: id });
|
|
6169
|
+
return json(200, { status: "collected", replayed: false, wallet: await readWallet(player) });
|
|
6170
|
+
}
|
|
5906
6171
|
async function route(request, sub, method) {
|
|
5907
|
-
if (method === "GET" && sub === "/health") return json(200, { ok: true, setupRequired: false, sandbox: options.sandbox });
|
|
6172
|
+
if (method === "GET" && sub === "/health") return json(200, { ok: true, setupRequired: false, sandbox: options.sandbox, demo: !!options.demoProjectId });
|
|
5908
6173
|
if (method === "GET" && sub === "/catalog") return catalog();
|
|
5909
6174
|
if (method === "POST" && sub === "/session") return signIn(request);
|
|
5910
6175
|
if (method === "POST" && sub === "/session/end") return signOut(request);
|
|
@@ -5920,6 +6185,15 @@ function createInvoGameServer(options) {
|
|
|
5920
6185
|
if (method === "POST" && sub === "/earn") return earn(request);
|
|
5921
6186
|
if (method === "POST" && sub === "/events") return events(request);
|
|
5922
6187
|
if (method === "GET" && sub === "/rewards") return rewards(request);
|
|
6188
|
+
if (method === "GET" && sub === "/transfers/status") return json(200, transferStatus());
|
|
6189
|
+
if (method === "POST" && sub === "/transfers/token") return transferToken(request);
|
|
6190
|
+
if (method === "POST" && sub === "/transfers") return startTransfer(request);
|
|
6191
|
+
if (method === "GET" && sub === "/transfers/pending") return pendingMoves(request);
|
|
6192
|
+
const move = /^\/transfers\/([^/]+)\/(approve|collect)$/.exec(sub);
|
|
6193
|
+
if (method === "POST" && move) {
|
|
6194
|
+
const id = decodeURIComponent(move[1]);
|
|
6195
|
+
return move[2] === "approve" ? approveMove(request, id) : collectMove(request, id);
|
|
6196
|
+
}
|
|
5923
6197
|
return json(404, { error: { code: "NOT_FOUND", message: "No such route." } });
|
|
5924
6198
|
}
|
|
5925
6199
|
return {
|
|
@@ -5958,7 +6232,7 @@ function invoGameServerFromEnv(options) {
|
|
|
5958
6232
|
...webhookSecrets.length ? [] : ["INVO_WEBHOOK_SECRET"]
|
|
5959
6233
|
];
|
|
5960
6234
|
if (missing.length) {
|
|
5961
|
-
return { server: setupRequiredServer(options.economy, missing, sandboxNow(), options.basePath), missing, sandbox: sandboxNow(), environment: envNow() };
|
|
6235
|
+
return { server: setupRequiredServer(options.economy, missing, sandboxNow(), options.basePath, demo), missing, sandbox: sandboxNow(), environment: envNow(), demo };
|
|
5962
6236
|
}
|
|
5963
6237
|
const baseFetch = options.fetch ?? ((input, init) => fetch(input, init));
|
|
5964
6238
|
const projectId = demoProject?.projectId ?? ((options.projectId ?? env["INVO_PROJECT_ID"])?.trim() || void 0);
|
|
@@ -5990,10 +6264,16 @@ function invoGameServerFromEnv(options) {
|
|
|
5990
6264
|
},
|
|
5991
6265
|
basePath: options.basePath,
|
|
5992
6266
|
publicUrl: env["PUBLIC_URL"] || void 0,
|
|
5993
|
-
log: options.log
|
|
6267
|
+
log: options.log,
|
|
6268
|
+
transfers: (() => {
|
|
6269
|
+
const t = env["INVO_TRANSFERS"]?.trim().toLowerCase();
|
|
6270
|
+
return t === "on" ? true : t === "off" ? false : "auto";
|
|
6271
|
+
})(),
|
|
6272
|
+
environment: envNow,
|
|
6273
|
+
playerApiBaseUrl: () => explicitBase || (state.environment === "production" ? PRODUCTION_BASE_URL : state.environment === "sandbox" ? SANDBOX_BASE_URL : null)
|
|
5994
6274
|
};
|
|
5995
6275
|
const server = createInvoGameServer(serverOptions);
|
|
5996
|
-
return { server, missing, sandbox: sandboxNow(), environment: envNow() };
|
|
6276
|
+
return { server, missing, sandbox: sandboxNow(), environment: envNow(), demo };
|
|
5997
6277
|
}
|
|
5998
6278
|
function newProjectId(now = Date.now()) {
|
|
5999
6279
|
const A = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
@@ -6008,7 +6288,7 @@ function newProjectId(now = Date.now()) {
|
|
|
6008
6288
|
for (let i = 0; i < 16; i++) rand += A[bytes[i] % 32];
|
|
6009
6289
|
return "proj_" + time + rand;
|
|
6010
6290
|
}
|
|
6011
|
-
function setupRequiredServer(economy, missing, sandbox, basePathOpt) {
|
|
6291
|
+
function setupRequiredServer(economy, missing, sandbox, basePathOpt, demo = false) {
|
|
6012
6292
|
const basePath = (basePathOpt ?? "/api/invo").replace(/\/+$/, "");
|
|
6013
6293
|
const message = `Add ${missing.join(" and ")} to your environment (on Replit: Tools \u2192 Secrets), then restart.`;
|
|
6014
6294
|
return {
|
|
@@ -6017,9 +6297,9 @@ function setupRequiredServer(economy, missing, sandbox, basePathOpt) {
|
|
|
6017
6297
|
const url = new URL(request.url);
|
|
6018
6298
|
if (url.pathname !== basePath && !url.pathname.startsWith(basePath + "/")) return null;
|
|
6019
6299
|
const sub = url.pathname.slice(basePath.length) || "/";
|
|
6020
|
-
if (request.method === "GET" && sub === "/health") return json(200, { ok: true, setupRequired: true, missing, sandbox });
|
|
6300
|
+
if (request.method === "GET" && sub === "/health") return json(200, { ok: true, setupRequired: true, missing, sandbox, demo });
|
|
6021
6301
|
if (request.method === "GET" && sub === "/catalog") {
|
|
6022
|
-
const body = { premium: { name: economy.premium.name, packs: economy.premium.packs }, soft: { name: economy.soft.name }, items: economy.items, sandbox };
|
|
6302
|
+
const body = { premium: { name: economy.premium.name, packs: economy.premium.packs }, soft: { name: economy.soft.name }, items: economy.items, sandbox, demo, playerFields: { phone: demo ? "hidden" : "first_sign_in" } };
|
|
6023
6303
|
return json(200, body);
|
|
6024
6304
|
}
|
|
6025
6305
|
return json(503, { error: { code: "INVO_SETUP_REQUIRED", message } });
|
package/dist/game-server.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { I as InvoServer, a as InvoEnvironment } from './server-
|
|
2
|
-
export { D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, P as PRODUCTION_BASE_URL, S as SANDBOX_BASE_URL, b as baseUrlForKey, i as isDemoKey, r as resolveEnvironment, v as verifyInvoSignature } from './server-
|
|
3
|
-
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-
|
|
4
|
-
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameWallet } from './types-
|
|
5
|
-
export { I as InvoError } from './types-
|
|
6
|
-
export { S as SDK_VERSION } from './version-
|
|
1
|
+
import { I as InvoServer, a as InvoEnvironment } from './server-DEh9wjF2.cjs';
|
|
2
|
+
export { D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, P as PRODUCTION_BASE_URL, S as SANDBOX_BASE_URL, b as baseUrlForKey, i as isDemoKey, r as resolveEnvironment, v as verifyInvoSignature } from './server-DEh9wjF2.cjs';
|
|
3
|
+
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-jUxfYjiD.cjs';
|
|
4
|
+
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameTransferInput, n as GameTransferKind, o as GameTransferStart, p as GameTransferStatus, q as GameWallet } from './types-jUxfYjiD.cjs';
|
|
5
|
+
export { I as InvoError } from './types-BTbZicgj.cjs';
|
|
6
|
+
export { S as SDK_VERSION } from './version-DfVkILOj.cjs';
|
|
7
|
+
import './loyalty-events-CmDw2ZoR.cjs';
|
|
7
8
|
|
|
8
9
|
interface StoredPlayer {
|
|
9
10
|
id: string;
|
|
@@ -62,6 +63,29 @@ interface GameStoreState {
|
|
|
62
63
|
inventory: Record<string, Record<string, number>>;
|
|
63
64
|
/** Webhook idempotency key → time processed. */
|
|
64
65
|
webhooks: Record<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* Public demo key only (3.30.0): sends and transfers between players of this project, by
|
|
68
|
+
* INVO transaction id. The server approves them in INVO's demo sandbox and keeps the claim
|
|
69
|
+
* code so the recipient can collect. Absent in stores written before 3.30.0.
|
|
70
|
+
*/
|
|
71
|
+
demoMoves?: Record<string, StoredDemoMove>;
|
|
72
|
+
}
|
|
73
|
+
interface StoredDemoMove {
|
|
74
|
+
transactionId: string;
|
|
75
|
+
kind: "send" | "transfer";
|
|
76
|
+
fromPlayerId: string;
|
|
77
|
+
fromName: string;
|
|
78
|
+
/** The recipient's demo email (already mapped with `toDemoEmail`). */
|
|
79
|
+
toEmail: string;
|
|
80
|
+
amount: string;
|
|
81
|
+
currencyName: string;
|
|
82
|
+
/** True when it lands in this game, so a player of this game can collect it. */
|
|
83
|
+
sameGame: boolean;
|
|
84
|
+
destinationName: string;
|
|
85
|
+
status: "started" | "approved" | "collected";
|
|
86
|
+
claimCode: string | null;
|
|
87
|
+
claimCodeExpiresAt: string | null;
|
|
88
|
+
createdAt: string;
|
|
65
89
|
}
|
|
66
90
|
interface GameStore {
|
|
67
91
|
/** Read a consistent snapshot. Do not mutate it. */
|
|
@@ -115,6 +139,16 @@ interface InvoGameServerOptions {
|
|
|
115
139
|
* address or number ever reaches INVO. {@link invoGameServerFromEnv} sets it for you.
|
|
116
140
|
*/
|
|
117
141
|
demoProjectId?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Player-to-player transfers and sends (3.30.0). `"auto"` (the default) turns them on for
|
|
144
|
+
* the public demo key and in production, and off on other sandbox keys; `true` or `false`
|
|
145
|
+
* forces it. {@link invoGameServerFromEnv} reads `INVO_TRANSFERS` (`on`, `off`, `auto`).
|
|
146
|
+
*/
|
|
147
|
+
transfers?: boolean | "auto";
|
|
148
|
+
/** Where the key's environment stands, for `transfers: "auto"`. Default: from `sandbox`. */
|
|
149
|
+
environment?: () => InvoEnvironment | "resolving";
|
|
150
|
+
/** INVO's API base for the browser's player-token calls, or null while unknown. */
|
|
151
|
+
playerApiBaseUrl?: () => string | null;
|
|
118
152
|
}
|
|
119
153
|
interface InvoGameServer {
|
|
120
154
|
readonly basePath: string;
|
|
@@ -171,6 +205,8 @@ interface InvoGameServerSetup {
|
|
|
171
205
|
sandbox: boolean;
|
|
172
206
|
/** `"sandbox"`, `"production"`, or `"resolving"` while a key's environment is being looked up. */
|
|
173
207
|
environment: InvoEnvironment | "resolving";
|
|
208
|
+
/** True when the key is INVO's public demo key (3.29.1). */
|
|
209
|
+
demo: boolean;
|
|
174
210
|
}
|
|
175
211
|
/**
|
|
176
212
|
* Build the game server from environment variables (Replit Secrets, `.env`, your host's
|
|
@@ -214,8 +250,10 @@ declare const DEFAULT_PROJECT_FILE = ".invo/project.json";
|
|
|
214
250
|
/** What the project file holds. Secrets: keep the file out of version control. */
|
|
215
251
|
interface DemoProjectFile {
|
|
216
252
|
projectId: string;
|
|
217
|
-
/** The public host the project was registered from (remix detection). */
|
|
253
|
+
/** The public host the project was registered from (remix detection outside Replit). */
|
|
218
254
|
host?: string;
|
|
255
|
+
/** Replit's REPL_ID when the file was written. A different REPL_ID means a remix. */
|
|
256
|
+
replId?: string;
|
|
219
257
|
webhookUrl?: string;
|
|
220
258
|
webhookSecret?: string;
|
|
221
259
|
registrationToken?: string;
|
|
@@ -230,13 +268,13 @@ declare function toDemoEmail(email: string, projectId: string): string;
|
|
|
230
268
|
declare function demoPhoneFor(email: string): string;
|
|
231
269
|
/**
|
|
232
270
|
* This fork's project, from `INVO_PROJECT_ID`, else the project file, else a new id written to
|
|
233
|
-
* the file.
|
|
234
|
-
* was copied by a remix: a fresh project id replaces it.
|
|
271
|
+
* the file. A project file copied by a remix (see `sameFork`) is replaced by a fresh project id.
|
|
235
272
|
*/
|
|
236
273
|
declare function loadProject(opts?: {
|
|
237
274
|
file?: string;
|
|
238
275
|
publicUrl?: string;
|
|
239
276
|
projectId?: string;
|
|
277
|
+
replId?: string;
|
|
240
278
|
}): DemoProjectFile;
|
|
241
279
|
interface RegisterProjectOptions {
|
|
242
280
|
/** The public demo key (`ivsdk_demo_...`). */
|
|
@@ -247,6 +285,8 @@ interface RegisterProjectOptions {
|
|
|
247
285
|
projectId?: string;
|
|
248
286
|
baseUrl?: string;
|
|
249
287
|
fetch?: typeof fetch;
|
|
288
|
+
/** Overrides Replit's REPL_ID (tests). */
|
|
289
|
+
replId?: string;
|
|
250
290
|
}
|
|
251
291
|
interface RegisteredProject {
|
|
252
292
|
projectId: string;
|
package/dist/game-server.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { I as InvoServer, a as InvoEnvironment } from './server-
|
|
2
|
-
export { D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, P as PRODUCTION_BASE_URL, S as SANDBOX_BASE_URL, b as baseUrlForKey, i as isDemoKey, r as resolveEnvironment, v as verifyInvoSignature } from './server-
|
|
3
|
-
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-
|
|
4
|
-
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameWallet } from './types-
|
|
5
|
-
export { I as InvoError } from './types-
|
|
6
|
-
export { S as SDK_VERSION } from './version-
|
|
1
|
+
import { I as InvoServer, a as InvoEnvironment } from './server-B0mvlGFY.js';
|
|
2
|
+
export { D as DEMO_KEY_PREFIX, E as EnvironmentUnknownError, P as PRODUCTION_BASE_URL, S as SANDBOX_BASE_URL, b as baseUrlForKey, i as isDemoKey, r as resolveEnvironment, v as verifyInvoSignature } from './server-B0mvlGFY.js';
|
|
3
|
+
import { G as GameCurrencyKind, a as GamePurchaseStatus, b as GameEconomyConfig } from './types-jUxfYjiD.js';
|
|
4
|
+
export { c as GameCatalog, d as GameCatalogItem, e as GameCheckout, f as GameCurrencyBalance, g as GameErrorBody, h as GameItemPurchase, i as GamePlayer, j as GamePremiumPack, k as GamePurchase, l as GameSession, m as GameTransferInput, n as GameTransferKind, o as GameTransferStart, p as GameTransferStatus, q as GameWallet } from './types-jUxfYjiD.js';
|
|
5
|
+
export { I as InvoError } from './types-BTbZicgj.js';
|
|
6
|
+
export { S as SDK_VERSION } from './version-DfVkILOj.js';
|
|
7
|
+
import './loyalty-events-CmDw2ZoR.js';
|
|
7
8
|
|
|
8
9
|
interface StoredPlayer {
|
|
9
10
|
id: string;
|
|
@@ -62,6 +63,29 @@ interface GameStoreState {
|
|
|
62
63
|
inventory: Record<string, Record<string, number>>;
|
|
63
64
|
/** Webhook idempotency key → time processed. */
|
|
64
65
|
webhooks: Record<string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* Public demo key only (3.30.0): sends and transfers between players of this project, by
|
|
68
|
+
* INVO transaction id. The server approves them in INVO's demo sandbox and keeps the claim
|
|
69
|
+
* code so the recipient can collect. Absent in stores written before 3.30.0.
|
|
70
|
+
*/
|
|
71
|
+
demoMoves?: Record<string, StoredDemoMove>;
|
|
72
|
+
}
|
|
73
|
+
interface StoredDemoMove {
|
|
74
|
+
transactionId: string;
|
|
75
|
+
kind: "send" | "transfer";
|
|
76
|
+
fromPlayerId: string;
|
|
77
|
+
fromName: string;
|
|
78
|
+
/** The recipient's demo email (already mapped with `toDemoEmail`). */
|
|
79
|
+
toEmail: string;
|
|
80
|
+
amount: string;
|
|
81
|
+
currencyName: string;
|
|
82
|
+
/** True when it lands in this game, so a player of this game can collect it. */
|
|
83
|
+
sameGame: boolean;
|
|
84
|
+
destinationName: string;
|
|
85
|
+
status: "started" | "approved" | "collected";
|
|
86
|
+
claimCode: string | null;
|
|
87
|
+
claimCodeExpiresAt: string | null;
|
|
88
|
+
createdAt: string;
|
|
65
89
|
}
|
|
66
90
|
interface GameStore {
|
|
67
91
|
/** Read a consistent snapshot. Do not mutate it. */
|
|
@@ -115,6 +139,16 @@ interface InvoGameServerOptions {
|
|
|
115
139
|
* address or number ever reaches INVO. {@link invoGameServerFromEnv} sets it for you.
|
|
116
140
|
*/
|
|
117
141
|
demoProjectId?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Player-to-player transfers and sends (3.30.0). `"auto"` (the default) turns them on for
|
|
144
|
+
* the public demo key and in production, and off on other sandbox keys; `true` or `false`
|
|
145
|
+
* forces it. {@link invoGameServerFromEnv} reads `INVO_TRANSFERS` (`on`, `off`, `auto`).
|
|
146
|
+
*/
|
|
147
|
+
transfers?: boolean | "auto";
|
|
148
|
+
/** Where the key's environment stands, for `transfers: "auto"`. Default: from `sandbox`. */
|
|
149
|
+
environment?: () => InvoEnvironment | "resolving";
|
|
150
|
+
/** INVO's API base for the browser's player-token calls, or null while unknown. */
|
|
151
|
+
playerApiBaseUrl?: () => string | null;
|
|
118
152
|
}
|
|
119
153
|
interface InvoGameServer {
|
|
120
154
|
readonly basePath: string;
|
|
@@ -171,6 +205,8 @@ interface InvoGameServerSetup {
|
|
|
171
205
|
sandbox: boolean;
|
|
172
206
|
/** `"sandbox"`, `"production"`, or `"resolving"` while a key's environment is being looked up. */
|
|
173
207
|
environment: InvoEnvironment | "resolving";
|
|
208
|
+
/** True when the key is INVO's public demo key (3.29.1). */
|
|
209
|
+
demo: boolean;
|
|
174
210
|
}
|
|
175
211
|
/**
|
|
176
212
|
* Build the game server from environment variables (Replit Secrets, `.env`, your host's
|
|
@@ -214,8 +250,10 @@ declare const DEFAULT_PROJECT_FILE = ".invo/project.json";
|
|
|
214
250
|
/** What the project file holds. Secrets: keep the file out of version control. */
|
|
215
251
|
interface DemoProjectFile {
|
|
216
252
|
projectId: string;
|
|
217
|
-
/** The public host the project was registered from (remix detection). */
|
|
253
|
+
/** The public host the project was registered from (remix detection outside Replit). */
|
|
218
254
|
host?: string;
|
|
255
|
+
/** Replit's REPL_ID when the file was written. A different REPL_ID means a remix. */
|
|
256
|
+
replId?: string;
|
|
219
257
|
webhookUrl?: string;
|
|
220
258
|
webhookSecret?: string;
|
|
221
259
|
registrationToken?: string;
|
|
@@ -230,13 +268,13 @@ declare function toDemoEmail(email: string, projectId: string): string;
|
|
|
230
268
|
declare function demoPhoneFor(email: string): string;
|
|
231
269
|
/**
|
|
232
270
|
* This fork's project, from `INVO_PROJECT_ID`, else the project file, else a new id written to
|
|
233
|
-
* the file.
|
|
234
|
-
* was copied by a remix: a fresh project id replaces it.
|
|
271
|
+
* the file. A project file copied by a remix (see `sameFork`) is replaced by a fresh project id.
|
|
235
272
|
*/
|
|
236
273
|
declare function loadProject(opts?: {
|
|
237
274
|
file?: string;
|
|
238
275
|
publicUrl?: string;
|
|
239
276
|
projectId?: string;
|
|
277
|
+
replId?: string;
|
|
240
278
|
}): DemoProjectFile;
|
|
241
279
|
interface RegisterProjectOptions {
|
|
242
280
|
/** The public demo key (`ivsdk_demo_...`). */
|
|
@@ -247,6 +285,8 @@ interface RegisterProjectOptions {
|
|
|
247
285
|
projectId?: string;
|
|
248
286
|
baseUrl?: string;
|
|
249
287
|
fetch?: typeof fetch;
|
|
288
|
+
/** Overrides Replit's REPL_ID (tests). */
|
|
289
|
+
replId?: string;
|
|
250
290
|
}
|
|
251
291
|
interface RegisteredProject {
|
|
252
292
|
projectId: string;
|