@forgezero/providers 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -81
- package/dist/billing.d.ts +305 -0
- package/dist/{chain.js → billing.js} +258 -143
- package/dist/database.js +1 -1
- package/dist/email.js +1 -1
- package/dist/git.d.ts +108 -40
- package/dist/git.js +41 -19
- package/dist/http.d.ts +9 -12
- package/dist/http.js +8 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pool.js +7 -6
- package/dist/storage.js +1 -1
- package/dist/translation.js +1 -1
- package/package.json +6 -10
- package/dist/binance.d.ts +0 -27
- package/dist/binance.js +0 -704
- package/dist/chain.d.ts +0 -99
|
@@ -336,155 +336,270 @@ function createService(definition, methods, options = {}) {
|
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
338
|
}
|
|
339
|
-
var VERSION = "0.1.
|
|
339
|
+
var VERSION = "0.1.25";
|
|
340
340
|
|
|
341
|
-
// src/
|
|
342
|
-
var
|
|
343
|
-
var
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
method: "request",
|
|
357
|
-
label: "EVM JSON-RPC node",
|
|
358
|
-
multiInstance: true,
|
|
359
|
-
credentials: {
|
|
360
|
-
type: "object",
|
|
361
|
-
properties: {
|
|
362
|
-
url: { type: "string", writeOnly: true },
|
|
363
|
-
bearer: { type: "string", writeOnly: true }
|
|
341
|
+
// src/billing.ts
|
|
342
|
+
var PAYMENT_PROVIDER_KEYS = ["stripe:v1", "paypal:v1", "razorpay:v1"];
|
|
343
|
+
var paymentProviderDefinitions = [
|
|
344
|
+
{
|
|
345
|
+
id: "stripe",
|
|
346
|
+
label: "Stripe",
|
|
347
|
+
multiInstance: true,
|
|
348
|
+
config: {
|
|
349
|
+
type: "object",
|
|
350
|
+
properties: {
|
|
351
|
+
providerApiVersion: { type: "string", minLength: 4, maxLength: 64 },
|
|
352
|
+
mode: { type: "string", enum: ["test", "live"] }
|
|
353
|
+
},
|
|
354
|
+
required: ["providerApiVersion", "mode"],
|
|
355
|
+
additionalProperties: false
|
|
364
356
|
},
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
timeoutMs: { type: "integer" }
|
|
357
|
+
credentials: {
|
|
358
|
+
type: "object",
|
|
359
|
+
properties: {
|
|
360
|
+
secretKey: { type: "string", minLength: 16, maxLength: 512, writeOnly: true },
|
|
361
|
+
webhookSecret: { type: "string", minLength: 16, maxLength: 512, writeOnly: true }
|
|
362
|
+
},
|
|
363
|
+
required: ["secretKey", "webhookSecret"],
|
|
364
|
+
additionalProperties: false
|
|
374
365
|
},
|
|
375
|
-
|
|
376
|
-
additionalProperties: false
|
|
366
|
+
methods: {}
|
|
377
367
|
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
code: body.error.code
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
if (body.result === undefined) {
|
|
406
|
-
throw new ProviderError("RPC_EMPTY", `${method}: no result`);
|
|
407
|
-
}
|
|
408
|
-
return body.result;
|
|
409
|
-
};
|
|
410
|
-
switch (call.op) {
|
|
411
|
-
case "head":
|
|
412
|
-
return { op: "head", block: hexToNumber(await rpc("eth_blockNumber", [])) };
|
|
413
|
-
case "balance":
|
|
414
|
-
return {
|
|
415
|
-
op: "balance",
|
|
416
|
-
wei: BigInt(await rpc("eth_getBalance", [call.address, call.block ?? "latest"]))
|
|
417
|
-
};
|
|
418
|
-
case "call":
|
|
419
|
-
return {
|
|
420
|
-
op: "call",
|
|
421
|
-
data: await rpc("eth_call", [
|
|
422
|
-
{ to: call.to, data: call.data },
|
|
423
|
-
call.block ?? "latest"
|
|
424
|
-
])
|
|
425
|
-
};
|
|
426
|
-
case "logs": {
|
|
427
|
-
const span = call.toBlock - call.fromBlock + 1;
|
|
428
|
-
const cap = config.maxLogRange ?? 2000;
|
|
429
|
-
if (span > cap) {
|
|
430
|
-
throw new ProviderError("RPC_RANGE_TOO_WIDE", `Asked for ${span} blocks; this node allows ${cap}. Split the range.`);
|
|
431
|
-
}
|
|
432
|
-
const logs = await rpc("eth_getLogs", [
|
|
433
|
-
{
|
|
434
|
-
fromBlock: `0x${call.fromBlock.toString(16)}`,
|
|
435
|
-
toBlock: `0x${call.toBlock.toString(16)}`,
|
|
436
|
-
...call.address ? { address: call.address } : {},
|
|
437
|
-
...call.topics ? { topics: call.topics } : {}
|
|
438
|
-
}
|
|
439
|
-
]);
|
|
440
|
-
return {
|
|
441
|
-
op: "logs",
|
|
442
|
-
logs: logs.map((log) => ({
|
|
443
|
-
transactionHash: log.transactionHash,
|
|
444
|
-
logIndex: hexToNumber(log.logIndex),
|
|
445
|
-
blockNumber: hexToNumber(log.blockNumber),
|
|
446
|
-
address: log.address,
|
|
447
|
-
topics: log.topics,
|
|
448
|
-
data: log.data
|
|
449
|
-
}))
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
case "nonce":
|
|
453
|
-
return {
|
|
454
|
-
op: "nonce",
|
|
455
|
-
nonce: BigInt(await rpc("eth_getTransactionCount", [call.address, call.block ?? "pending"]))
|
|
456
|
-
};
|
|
457
|
-
case "send":
|
|
458
|
-
return { op: "send", hash: await rpc("eth_sendRawTransaction", [call.raw]) };
|
|
459
|
-
case "receipt": {
|
|
460
|
-
const receipt = await rpc("eth_getTransactionReceipt", [call.hash]);
|
|
461
|
-
if (!receipt)
|
|
462
|
-
return { op: "receipt", receipt: null };
|
|
463
|
-
return {
|
|
464
|
-
op: "receipt",
|
|
465
|
-
receipt: {
|
|
466
|
-
hash: call.hash,
|
|
467
|
-
blockNumber: hexToNumber(receipt.blockNumber ?? "0x0"),
|
|
468
|
-
success: receipt.status === "0x1"
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}
|
|
368
|
+
{
|
|
369
|
+
id: "paypal",
|
|
370
|
+
label: "PayPal",
|
|
371
|
+
multiInstance: true,
|
|
372
|
+
config: {
|
|
373
|
+
type: "object",
|
|
374
|
+
properties: {
|
|
375
|
+
providerApiVersion: { type: "string", minLength: 2, maxLength: 64 },
|
|
376
|
+
environment: { type: "string", enum: ["sandbox", "live"] }
|
|
377
|
+
},
|
|
378
|
+
required: ["providerApiVersion", "environment"],
|
|
379
|
+
additionalProperties: false
|
|
380
|
+
},
|
|
381
|
+
credentials: {
|
|
382
|
+
type: "object",
|
|
383
|
+
properties: {
|
|
384
|
+
clientId: { type: "string", minLength: 10, maxLength: 512, writeOnly: true },
|
|
385
|
+
clientSecret: { type: "string", minLength: 10, maxLength: 512, writeOnly: true },
|
|
386
|
+
webhookId: { type: "string", minLength: 4, maxLength: 256, writeOnly: true }
|
|
387
|
+
},
|
|
388
|
+
required: ["clientId", "clientSecret", "webhookId"],
|
|
389
|
+
additionalProperties: false
|
|
390
|
+
},
|
|
391
|
+
methods: {}
|
|
473
392
|
},
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
393
|
+
{
|
|
394
|
+
id: "razorpay",
|
|
395
|
+
label: "Razorpay",
|
|
396
|
+
multiInstance: true,
|
|
397
|
+
config: {
|
|
398
|
+
type: "object",
|
|
399
|
+
properties: {
|
|
400
|
+
providerApiVersion: { type: "string", minLength: 2, maxLength: 64 },
|
|
401
|
+
mode: { type: "string", enum: ["test", "live"] }
|
|
402
|
+
},
|
|
403
|
+
required: ["providerApiVersion", "mode"],
|
|
404
|
+
additionalProperties: false
|
|
405
|
+
},
|
|
406
|
+
credentials: {
|
|
407
|
+
type: "object",
|
|
408
|
+
properties: {
|
|
409
|
+
keyId: { type: "string", minLength: 8, maxLength: 256, writeOnly: true },
|
|
410
|
+
keySecret: { type: "string", minLength: 8, maxLength: 512, writeOnly: true },
|
|
411
|
+
webhookSecret: { type: "string", minLength: 8, maxLength: 512, writeOnly: true }
|
|
412
|
+
},
|
|
413
|
+
required: ["keyId", "keySecret", "webhookSecret"],
|
|
414
|
+
additionalProperties: false
|
|
415
|
+
},
|
|
416
|
+
methods: {}
|
|
417
|
+
}
|
|
418
|
+
];
|
|
419
|
+
var billingService = defineService({
|
|
420
|
+
key: "billing",
|
|
421
|
+
methods: {
|
|
422
|
+
createHostedSetup: serviceMethod(),
|
|
423
|
+
completeHostedSetup: serviceMethod(),
|
|
424
|
+
createCustomer: serviceMethod(),
|
|
425
|
+
charge: serviceMethod(),
|
|
426
|
+
detachPaymentMethod: serviceMethod(),
|
|
427
|
+
verifyWebhook: serviceMethod(),
|
|
428
|
+
reconcile: serviceMethod()
|
|
486
429
|
}
|
|
487
430
|
});
|
|
431
|
+
function required(value, field, maximum = 512) {
|
|
432
|
+
const result = value.trim();
|
|
433
|
+
if (!result || result.length > maximum)
|
|
434
|
+
throw new Error(`PAYMENT_${field.toUpperCase()}_INVALID`);
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
function assertHostedInput(input) {
|
|
438
|
+
required(input.tenantKey, "tenant");
|
|
439
|
+
required(input.idempotencyKey, "idempotency", 200);
|
|
440
|
+
for (const [field, value] of [["return_url", input.returnUrl], ["cancel_url", input.cancelUrl]]) {
|
|
441
|
+
const url = new URL(required(value, field, 2048));
|
|
442
|
+
if (url.protocol !== "https:")
|
|
443
|
+
throw new Error(`PAYMENT_${field.toUpperCase()}_INVALID`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function assertChargeInput(input) {
|
|
447
|
+
required(input.tenantKey, "tenant");
|
|
448
|
+
required(input.invoiceKey, "invoice");
|
|
449
|
+
required(input.providerCustomerReference, "customer_reference");
|
|
450
|
+
required(input.providerPaymentMethodReference, "method_reference");
|
|
451
|
+
required(input.idempotencyKey, "idempotency", 200);
|
|
452
|
+
if (!/^[1-9][0-9]*$/.test(input.amountMinor))
|
|
453
|
+
throw new Error("PAYMENT_AMOUNT_INVALID");
|
|
454
|
+
if (input.currency !== "USD")
|
|
455
|
+
throw new Error("PAYMENT_CURRENCY_INVALID");
|
|
456
|
+
}
|
|
457
|
+
function assertSetupCompletion(input) {
|
|
458
|
+
required(input.tenantKey, "tenant");
|
|
459
|
+
required(input.setupReference, "setup_reference", 512);
|
|
460
|
+
required(input.idempotencyKey, "idempotency", 200);
|
|
461
|
+
}
|
|
462
|
+
function assertHostedResult(value) {
|
|
463
|
+
const hostedUrl = new URL(required(value.hostedUrl, "hosted_url", 2048));
|
|
464
|
+
if (hostedUrl.protocol !== "https:" || hostedUrl.username || hostedUrl.password)
|
|
465
|
+
throw new Error("PAYMENT_HOSTED_URL_INVALID");
|
|
466
|
+
required(value.setupReference, "setup_reference", 512);
|
|
467
|
+
if (!Number.isSafeInteger(value.expiresAtTs) || value.expiresAtTs <= Date.now())
|
|
468
|
+
throw new Error("PAYMENT_SETUP_EXPIRY_INVALID");
|
|
469
|
+
return { ...value, hostedUrl: hostedUrl.toString() };
|
|
470
|
+
}
|
|
471
|
+
function assertCompletionResult(value) {
|
|
472
|
+
required(value.providerPaymentMethodReference, "method_reference", 512);
|
|
473
|
+
if (value.providerCustomerReference !== undefined)
|
|
474
|
+
required(value.providerCustomerReference, "customer_reference", 512);
|
|
475
|
+
const display = value.display;
|
|
476
|
+
if (!display || !["card", "bank", "upi", "paypal", "other"].includes(display.type))
|
|
477
|
+
throw new Error("PAYMENT_DISPLAY_INVALID");
|
|
478
|
+
for (const [field, item, maximum] of [
|
|
479
|
+
["brand", display.brand, 80],
|
|
480
|
+
["last4", display.last4, 8],
|
|
481
|
+
["label", display.label, 160]
|
|
482
|
+
]) {
|
|
483
|
+
if (item !== undefined)
|
|
484
|
+
required(item, `display_${field}`, maximum);
|
|
485
|
+
}
|
|
486
|
+
if (display.last4 !== undefined && !/^[A-Za-z0-9]{1,8}$/.test(display.last4))
|
|
487
|
+
throw new Error("PAYMENT_DISPLAY_LAST4_INVALID");
|
|
488
|
+
for (const value2 of [display.expiresMonth, display.expiresYear]) {
|
|
489
|
+
if (value2 !== undefined && !Number.isSafeInteger(value2))
|
|
490
|
+
throw new Error("PAYMENT_DISPLAY_EXPIRY_INVALID");
|
|
491
|
+
}
|
|
492
|
+
if (display.expiresMonth !== undefined && (display.expiresMonth < 1 || display.expiresMonth > 12))
|
|
493
|
+
throw new Error("PAYMENT_DISPLAY_EXPIRY_INVALID");
|
|
494
|
+
return structuredClone(value);
|
|
495
|
+
}
|
|
496
|
+
function assertCustomerResult(value) {
|
|
497
|
+
return { providerCustomerReference: required(value.providerCustomerReference, "customer_reference", 512) };
|
|
498
|
+
}
|
|
499
|
+
function assertChargeResult(value) {
|
|
500
|
+
const providerAttemptReference = required(value.providerAttemptReference, "attempt_reference", 512);
|
|
501
|
+
if (!["succeeded", "failed", "pending"].includes(value.status))
|
|
502
|
+
throw new Error("PAYMENT_STATUS_INVALID");
|
|
503
|
+
const failureCode = value.failureCode === undefined ? undefined : required(value.failureCode, "failure_code", 160);
|
|
504
|
+
return { providerAttemptReference, status: value.status, ...failureCode ? { failureCode } : {} };
|
|
505
|
+
}
|
|
506
|
+
function assertWebhookResult(value) {
|
|
507
|
+
const providerEventId = required(value.providerEventId, "event_id", 512);
|
|
508
|
+
const eventType = required(value.eventType, "event_type", 160);
|
|
509
|
+
const resourceReference = required(value.resourceReference, "resource_reference", 512);
|
|
510
|
+
if (!["succeeded", "failed", "pending"].includes(value.status))
|
|
511
|
+
throw new Error("PAYMENT_STATUS_INVALID");
|
|
512
|
+
if (!Number.isSafeInteger(value.occurredAtTs) || value.occurredAtTs < 0)
|
|
513
|
+
throw new Error("PAYMENT_EVENT_TIME_INVALID");
|
|
514
|
+
const failureCode = value.failureCode === undefined ? undefined : required(value.failureCode, "failure_code", 160);
|
|
515
|
+
return {
|
|
516
|
+
providerEventId,
|
|
517
|
+
eventType,
|
|
518
|
+
resourceReference,
|
|
519
|
+
status: value.status,
|
|
520
|
+
occurredAtTs: value.occurredAtTs,
|
|
521
|
+
...failureCode ? { failureCode } : {}
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function assertReconciliationResult(value) {
|
|
525
|
+
const providerAttemptReference = required(value.providerAttemptReference, "attempt_reference", 512);
|
|
526
|
+
if (!["succeeded", "failed", "pending", "not_found"].includes(value.status))
|
|
527
|
+
throw new Error("PAYMENT_STATUS_INVALID");
|
|
528
|
+
const failureCode = value.failureCode === undefined ? undefined : required(value.failureCode, "failure_code", 160);
|
|
529
|
+
return { providerAttemptReference, status: value.status, ...failureCode ? { failureCode } : {} };
|
|
530
|
+
}
|
|
531
|
+
function paymentProviderAdapter(args) {
|
|
532
|
+
const [provider, contractVersion] = args.key.split(":");
|
|
533
|
+
const providerApiVersion = required(args.providerApiVersion, "api_version", 100);
|
|
534
|
+
return Object.freeze({
|
|
535
|
+
key: args.key,
|
|
536
|
+
provider,
|
|
537
|
+
contractVersion,
|
|
538
|
+
providerApiVersion,
|
|
539
|
+
async createHostedSetup(input) {
|
|
540
|
+
assertHostedInput(input);
|
|
541
|
+
return assertHostedResult(await args.driver.createHostedSetup(input));
|
|
542
|
+
},
|
|
543
|
+
async completeHostedSetup(input) {
|
|
544
|
+
assertSetupCompletion(input);
|
|
545
|
+
return assertCompletionResult(await args.driver.completeHostedSetup(input));
|
|
546
|
+
},
|
|
547
|
+
async createCustomer(input) {
|
|
548
|
+
required(input.tenantKey, "tenant");
|
|
549
|
+
required(input.email, "email");
|
|
550
|
+
required(input.idempotencyKey, "idempotency", 200);
|
|
551
|
+
return assertCustomerResult(await args.driver.createCustomer(input));
|
|
552
|
+
},
|
|
553
|
+
async charge(input) {
|
|
554
|
+
assertChargeInput(input);
|
|
555
|
+
return assertChargeResult(await args.driver.charge(input));
|
|
556
|
+
},
|
|
557
|
+
async detachPaymentMethod(input) {
|
|
558
|
+
required(input.tenantKey, "tenant");
|
|
559
|
+
required(input.providerPaymentMethodReference, "method_reference");
|
|
560
|
+
required(input.idempotencyKey, "idempotency", 200);
|
|
561
|
+
return args.driver.detachPaymentMethod(input);
|
|
562
|
+
},
|
|
563
|
+
async verifyWebhook(input) {
|
|
564
|
+
if (!(input.rawBody instanceof Uint8Array) || input.rawBody.byteLength > 1048576) {
|
|
565
|
+
throw new Error("PAYMENT_WEBHOOK_BODY_INVALID");
|
|
566
|
+
}
|
|
567
|
+
return assertWebhookResult(await args.driver.verifyWebhook(input));
|
|
568
|
+
},
|
|
569
|
+
async reconcile(input) {
|
|
570
|
+
required(input.tenantKey, "tenant");
|
|
571
|
+
required(input.providerAttemptReference, "attempt_reference");
|
|
572
|
+
return assertReconciliationResult(await args.driver.reconcile(input));
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
function definePaymentProvider(args) {
|
|
577
|
+
const classify = args.classify ?? (() => "retryable");
|
|
578
|
+
const branch = (invoke) => defineProviderMethodBranches({
|
|
579
|
+
currentVersion: args.version,
|
|
580
|
+
versions: { [args.version]: { version: args.version, lifecycle: "current", invoke, classify } }
|
|
581
|
+
});
|
|
582
|
+
return defineProvider({
|
|
583
|
+
id: args.id,
|
|
584
|
+
label: args.label,
|
|
585
|
+
multiInstance: true,
|
|
586
|
+
config: args.config,
|
|
587
|
+
credentials: args.credentials,
|
|
588
|
+
methods: {
|
|
589
|
+
createHostedSetup: branch(args.driver.createHostedSetup),
|
|
590
|
+
completeHostedSetup: branch(args.driver.completeHostedSetup),
|
|
591
|
+
createCustomer: branch(args.driver.createCustomer),
|
|
592
|
+
charge: branch(args.driver.charge),
|
|
593
|
+
detachPaymentMethod: branch(args.driver.detachPaymentMethod),
|
|
594
|
+
verifyWebhook: branch(args.driver.verifyWebhook),
|
|
595
|
+
reconcile: branch(args.driver.reconcile)
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
488
599
|
export {
|
|
489
|
-
|
|
600
|
+
paymentProviderDefinitions,
|
|
601
|
+
paymentProviderAdapter,
|
|
602
|
+
definePaymentProvider,
|
|
603
|
+
billingService,
|
|
604
|
+
PAYMENT_PROVIDER_KEYS
|
|
490
605
|
};
|
package/dist/database.js
CHANGED
package/dist/email.js
CHANGED
package/dist/git.d.ts
CHANGED
|
@@ -1,8 +1,47 @@
|
|
|
1
1
|
import { type FailureKind, type InvokeContext, type ProviderDefinition } from './index';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* GitHub is one provider authority with two deliberately separate service
|
|
4
|
+
* bindings. OAuth Server receives only user-authorization methods; Git Connect
|
|
5
|
+
* receives only installation/repository methods. Both resolve the same
|
|
6
|
+
* provider instance and therefore the same Vault credential exactly once.
|
|
7
|
+
*/
|
|
8
|
+
export interface GitHubUserAuthorizationRequest {
|
|
9
|
+
intent: 'signin' | 'signup' | 'invite' | 'recover' | 'session';
|
|
10
|
+
returnTo: string;
|
|
11
|
+
state: string;
|
|
12
|
+
codeChallenge: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GitHubUserAuthorization {
|
|
15
|
+
url: string;
|
|
16
|
+
expiresAtTs: number;
|
|
17
|
+
}
|
|
18
|
+
export interface GitHubUserAuthorizationCompletion {
|
|
19
|
+
code: string;
|
|
20
|
+
state: string;
|
|
21
|
+
codeVerifier: string;
|
|
22
|
+
}
|
|
23
|
+
export interface GitHubVerifiedIdentity {
|
|
24
|
+
providerUserId: string;
|
|
25
|
+
email: string;
|
|
26
|
+
displayName?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GitHubUserGrant {
|
|
29
|
+
accessToken: string;
|
|
30
|
+
expiresAtTs?: number;
|
|
31
|
+
refreshToken?: string;
|
|
32
|
+
refreshTokenExpiresAtTs?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface GitHubUserGrantRefreshRequest {
|
|
35
|
+
refreshToken: string;
|
|
36
|
+
}
|
|
37
|
+
export interface GitHubUserGrantRevokeRequest {
|
|
38
|
+
accessToken: string;
|
|
39
|
+
}
|
|
40
|
+
export interface GitInstallation {
|
|
3
41
|
id: string;
|
|
4
|
-
|
|
5
|
-
|
|
42
|
+
accountId: string;
|
|
43
|
+
accountLabel: string;
|
|
44
|
+
accountKind: 'user' | 'organization';
|
|
6
45
|
}
|
|
7
46
|
export interface GitRepository {
|
|
8
47
|
id: string;
|
|
@@ -20,29 +59,46 @@ export interface GitCloneCredential {
|
|
|
20
59
|
token: string;
|
|
21
60
|
expiresAtTs: number;
|
|
22
61
|
}
|
|
23
|
-
export interface
|
|
24
|
-
|
|
62
|
+
export interface GitInstallationStartRequest {
|
|
63
|
+
returnTo: string;
|
|
64
|
+
state: string;
|
|
65
|
+
}
|
|
66
|
+
export interface GitInstallationStart {
|
|
67
|
+
url: string;
|
|
68
|
+
expiresAtTs: number;
|
|
69
|
+
}
|
|
70
|
+
export interface GitInstallationCompletionRequest {
|
|
71
|
+
installationId: string;
|
|
72
|
+
setupAction?: 'install' | 'update';
|
|
73
|
+
state: string;
|
|
74
|
+
}
|
|
75
|
+
export interface GitInstallationRequest {
|
|
76
|
+
installationId: string;
|
|
25
77
|
}
|
|
26
78
|
export interface GitRepositoryRequest {
|
|
27
|
-
|
|
79
|
+
installationId: string;
|
|
28
80
|
cursor?: string;
|
|
29
81
|
}
|
|
30
82
|
export interface GitBranchRequest {
|
|
31
|
-
|
|
83
|
+
installationId: string;
|
|
32
84
|
repository: string;
|
|
33
85
|
cursor?: string;
|
|
34
86
|
}
|
|
35
|
-
export interface GitWebhookRequest {
|
|
36
|
-
accountId: string;
|
|
37
|
-
repository: string;
|
|
38
|
-
callbackUrl: string;
|
|
39
|
-
secret: string;
|
|
40
|
-
events: readonly ['push'];
|
|
41
|
-
}
|
|
42
87
|
export interface GitCloneCredentialRequest {
|
|
43
|
-
|
|
88
|
+
installationId: string;
|
|
44
89
|
repository: string;
|
|
45
90
|
}
|
|
91
|
+
export interface GitWebhookVerificationRequest {
|
|
92
|
+
rawBody: Uint8Array;
|
|
93
|
+
signature: string;
|
|
94
|
+
deliveryId: string;
|
|
95
|
+
event: string;
|
|
96
|
+
}
|
|
97
|
+
export interface GitWebhookEvent {
|
|
98
|
+
deliveryId: string;
|
|
99
|
+
event: string;
|
|
100
|
+
payload: unknown;
|
|
101
|
+
}
|
|
46
102
|
export declare const githubAppConfigSchema: {
|
|
47
103
|
readonly type: "object";
|
|
48
104
|
readonly properties: {
|
|
@@ -59,8 +115,16 @@ export declare const githubAppConfigSchema: {
|
|
|
59
115
|
readonly type: "string";
|
|
60
116
|
readonly pattern: "^[a-z0-9][a-z0-9-]{0,99}$";
|
|
61
117
|
};
|
|
118
|
+
readonly providerVersion: {
|
|
119
|
+
readonly type: "string";
|
|
120
|
+
readonly pattern: "^github-app:[a-z0-9][a-z0-9.-]{0,31}$";
|
|
121
|
+
};
|
|
122
|
+
readonly verifiedAtTs: {
|
|
123
|
+
readonly type: "integer";
|
|
124
|
+
readonly minimum: 1;
|
|
125
|
+
};
|
|
62
126
|
};
|
|
63
|
-
readonly required: readonly ["clientId", "appId", "slug"];
|
|
127
|
+
readonly required: readonly ["clientId", "appId", "slug", "providerVersion", "verifiedAtTs"];
|
|
64
128
|
readonly additionalProperties: false;
|
|
65
129
|
};
|
|
66
130
|
export declare const githubAppCredentialSchema: {
|
|
@@ -88,37 +152,41 @@ export declare const githubAppCredentialSchema: {
|
|
|
88
152
|
readonly required: readonly ["clientSecret", "privateKey", "webhookSecret"];
|
|
89
153
|
readonly additionalProperties: false;
|
|
90
154
|
};
|
|
155
|
+
export declare const oauthServerService: import("./index").ServiceDefinition<"oauth-server", {
|
|
156
|
+
beginUserAuthorization: import("./index").ServiceMethodContract<GitHubUserAuthorizationRequest, GitHubUserAuthorization>;
|
|
157
|
+
completeUserAuthorization: import("./index").ServiceMethodContract<GitHubUserAuthorizationCompletion, GitHubUserGrant>;
|
|
158
|
+
readVerifiedIdentity: import("./index").ServiceMethodContract<GitHubUserGrant, GitHubVerifiedIdentity>;
|
|
159
|
+
refreshUserGrant: import("./index").ServiceMethodContract<GitHubUserGrantRefreshRequest, GitHubUserGrant>;
|
|
160
|
+
revokeUserGrant: import("./index").ServiceMethodContract<GitHubUserGrantRevokeRequest, void>;
|
|
161
|
+
}>;
|
|
91
162
|
export declare const gitConnectService: import("./index").ServiceDefinition<"git-connect", {
|
|
92
|
-
|
|
163
|
+
beginInstallation: import("./index").ServiceMethodContract<GitInstallationStartRequest, GitInstallationStart>;
|
|
164
|
+
completeInstallation: import("./index").ServiceMethodContract<GitInstallationCompletionRequest, GitInstallation>;
|
|
165
|
+
listInstallations: import("./index").ServiceMethodContract<Record<string, never>, readonly GitInstallation[]>;
|
|
93
166
|
listRepositories: import("./index").ServiceMethodContract<GitRepositoryRequest, readonly GitRepository[]>;
|
|
94
167
|
listBranches: import("./index").ServiceMethodContract<GitBranchRequest, readonly GitBranch[]>;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}>;
|
|
99
|
-
cloneCredential: import("./index").ServiceMethodContract<GitCloneCredentialRequest, GitCloneCredential>;
|
|
168
|
+
mintCloneCredential: import("./index").ServiceMethodContract<GitCloneCredentialRequest, GitCloneCredential>;
|
|
169
|
+
verifyWebhook: import("./index").ServiceMethodContract<GitWebhookVerificationRequest, GitWebhookEvent>;
|
|
170
|
+
disconnectInstallation: import("./index").ServiceMethodContract<GitInstallationRequest, void>;
|
|
100
171
|
}>;
|
|
101
|
-
export interface
|
|
102
|
-
|
|
172
|
+
export interface GitHubProviderAdapter {
|
|
173
|
+
beginUserAuthorization(context: InvokeContext, args: GitHubUserAuthorizationRequest): Promise<GitHubUserAuthorization>;
|
|
174
|
+
completeUserAuthorization(context: InvokeContext, args: GitHubUserAuthorizationCompletion): Promise<GitHubUserGrant>;
|
|
175
|
+
readVerifiedIdentity(context: InvokeContext, args: GitHubUserGrant): Promise<GitHubVerifiedIdentity>;
|
|
176
|
+
refreshUserGrant(context: InvokeContext, args: GitHubUserGrantRefreshRequest): Promise<GitHubUserGrant>;
|
|
177
|
+
revokeUserGrant(context: InvokeContext, args: GitHubUserGrantRevokeRequest): Promise<void>;
|
|
178
|
+
beginInstallation(context: InvokeContext, args: GitInstallationStartRequest): Promise<GitInstallationStart>;
|
|
179
|
+
completeInstallation(context: InvokeContext, args: GitInstallationCompletionRequest): Promise<GitInstallation>;
|
|
180
|
+
listInstallations(context: InvokeContext, args: Record<string, never>): Promise<readonly GitInstallation[]>;
|
|
103
181
|
listRepositories(context: InvokeContext, args: GitRepositoryRequest): Promise<readonly GitRepository[]>;
|
|
104
182
|
listBranches(context: InvokeContext, args: GitBranchRequest): Promise<readonly GitBranch[]>;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}>;
|
|
109
|
-
cloneCredential(context: InvokeContext, args: GitCloneCredentialRequest): Promise<GitCloneCredential>;
|
|
183
|
+
mintCloneCredential(context: InvokeContext, args: GitCloneCredentialRequest): Promise<GitCloneCredential>;
|
|
184
|
+
verifyWebhook(context: InvokeContext, args: GitWebhookVerificationRequest): Promise<GitWebhookEvent>;
|
|
185
|
+
disconnectInstallation(context: InvokeContext, args: GitInstallationRequest): Promise<void>;
|
|
110
186
|
}
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
* A GitHub App, GitLab OAuth application, self-hosted forge, or future provider
|
|
114
|
-
* supplies this adapter; the service keeps the same five typed operations.
|
|
115
|
-
*/
|
|
116
|
-
export declare function defineGitConnectProvider(args: {
|
|
117
|
-
id: string;
|
|
118
|
-
label: string;
|
|
187
|
+
/** Define the single GitHub App provider. No OAuth-App compatibility identity exists. */
|
|
188
|
+
export declare function defineGitHubProvider(args: {
|
|
119
189
|
version: string;
|
|
120
|
-
adapter:
|
|
121
|
-
credentials?: Record<string, unknown>;
|
|
122
|
-
config?: Record<string, unknown>;
|
|
190
|
+
adapter: GitHubProviderAdapter;
|
|
123
191
|
classify?: (error: unknown) => FailureKind;
|
|
124
192
|
}): ProviderDefinition;
|