@peable.to/shared-types 0.3.1-oxy-one.0 → 0.3.2-oxy-one.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/dist/cjs/billing-authority.js +24 -0
- package/dist/cjs/index.js +4 -1
- package/dist/esm/billing-authority.js +20 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/billing-authority.d.ts +3 -0
- package/dist/types/billing.d.ts +134 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canonicalBillingAuthority = canonicalBillingAuthority;
|
|
4
|
+
exports.canonicalBillingTaxQuote = canonicalBillingTaxQuote;
|
|
5
|
+
/** Canonical JSON v1: lexicographic object keys, array order preserved, UTF-8.
|
|
6
|
+
* Only finite safe integer amounts and plain JSON values are permitted. */
|
|
7
|
+
function encode(value) {
|
|
8
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
9
|
+
return JSON.stringify(value);
|
|
10
|
+
if (typeof value === 'number' && Number.isSafeInteger(value))
|
|
11
|
+
return JSON.stringify(value);
|
|
12
|
+
if (Array.isArray(value))
|
|
13
|
+
return `[${value.map(encode).join(',')}]`;
|
|
14
|
+
if (typeof value !== 'object' || value === null || Object.getPrototypeOf(value) !== Object.prototype)
|
|
15
|
+
throw new Error('Invalid authority JSON');
|
|
16
|
+
const object = value;
|
|
17
|
+
return `{${Object.keys(object).sort().filter((key) => object[key] !== undefined).map((key) => `${JSON.stringify(key)}:${encode(object[key])}`).join(',')}}`;
|
|
18
|
+
}
|
|
19
|
+
function canonicalBillingAuthority(authority) {
|
|
20
|
+
return encode({ schemaVersion: authority.schemaVersion, source: authority.source, invoice: authority.invoice, method: authority.method });
|
|
21
|
+
}
|
|
22
|
+
function canonicalBillingTaxQuote(authority) {
|
|
23
|
+
return encode({ schemaVersion: authority.schemaVersion, source: authority.source, quote: authority.quote });
|
|
24
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_STATUSES = exports.POST_SETTLEMENT_STATUSES = exports.reachesSettlementFromPayer = exports.canStillBePaid = exports.isValidStatusTransition = exports.isCurrencyCode = exports.decimalsFor = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
|
|
3
|
+
exports.canonicalBillingTaxQuote = exports.canonicalBillingAuthority = exports.BILLING_SUBSCRIPTION_STATUSES = exports.SOCIAL_SOURCE_REF_MAX_LENGTH = exports.SOCIAL_SOURCE_APP_MAX_LENGTH = exports.MERCHANT_ENVIRONMENTS = exports.verifyWebhook = exports.signWebhook = exports.CARD_ONLY_STATUSES = exports.CHAIN_ONLY_STATUSES = exports.PAYMENT_INTENT_RAILS = exports.PAYMENT_INTENT_STATUSES = exports.POST_SETTLEMENT_STATUSES = exports.reachesSettlementFromPayer = exports.canStillBePaid = exports.isValidStatusTransition = exports.isCurrencyCode = exports.decimalsFor = exports.CURRENCY_DECIMALS = exports.CURRENCY_CODES = exports.isBaseUnitString = exports.UNITS_PER_COIN = void 0;
|
|
4
4
|
// @peable.to/shared-types — public API for the Peable Gateway contract.
|
|
5
5
|
var money_1 = require("./money");
|
|
6
6
|
Object.defineProperty(exports, "UNITS_PER_COIN", { enumerable: true, get: function () { return money_1.UNITS_PER_COIN; } });
|
|
@@ -28,3 +28,6 @@ Object.defineProperty(exports, "SOCIAL_SOURCE_APP_MAX_LENGTH", { enumerable: tru
|
|
|
28
28
|
Object.defineProperty(exports, "SOCIAL_SOURCE_REF_MAX_LENGTH", { enumerable: true, get: function () { return social_1.SOCIAL_SOURCE_REF_MAX_LENGTH; } });
|
|
29
29
|
var billing_1 = require("./billing");
|
|
30
30
|
Object.defineProperty(exports, "BILLING_SUBSCRIPTION_STATUSES", { enumerable: true, get: function () { return billing_1.BILLING_SUBSCRIPTION_STATUSES; } });
|
|
31
|
+
var billing_authority_1 = require("./billing-authority");
|
|
32
|
+
Object.defineProperty(exports, "canonicalBillingAuthority", { enumerable: true, get: function () { return billing_authority_1.canonicalBillingAuthority; } });
|
|
33
|
+
Object.defineProperty(exports, "canonicalBillingTaxQuote", { enumerable: true, get: function () { return billing_authority_1.canonicalBillingTaxQuote; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Canonical JSON v1: lexicographic object keys, array order preserved, UTF-8.
|
|
2
|
+
* Only finite safe integer amounts and plain JSON values are permitted. */
|
|
3
|
+
function encode(value) {
|
|
4
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
5
|
+
return JSON.stringify(value);
|
|
6
|
+
if (typeof value === 'number' && Number.isSafeInteger(value))
|
|
7
|
+
return JSON.stringify(value);
|
|
8
|
+
if (Array.isArray(value))
|
|
9
|
+
return `[${value.map(encode).join(',')}]`;
|
|
10
|
+
if (typeof value !== 'object' || value === null || Object.getPrototypeOf(value) !== Object.prototype)
|
|
11
|
+
throw new Error('Invalid authority JSON');
|
|
12
|
+
const object = value;
|
|
13
|
+
return `{${Object.keys(object).sort().filter((key) => object[key] !== undefined).map((key) => `${JSON.stringify(key)}:${encode(object[key])}`).join(',')}}`;
|
|
14
|
+
}
|
|
15
|
+
export function canonicalBillingAuthority(authority) {
|
|
16
|
+
return encode({ schemaVersion: authority.schemaVersion, source: authority.source, invoice: authority.invoice, method: authority.method });
|
|
17
|
+
}
|
|
18
|
+
export function canonicalBillingTaxQuote(authority) {
|
|
19
|
+
return encode({ schemaVersion: authority.schemaVersion, source: authority.source, quote: authority.quote });
|
|
20
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { signWebhook, verifyWebhook } from './webhookSigner.js';
|
|
|
5
5
|
export { MERCHANT_ENVIRONMENTS, } from './merchant.js';
|
|
6
6
|
export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, } from './social.js';
|
|
7
7
|
export { BILLING_SUBSCRIPTION_STATUSES, } from './billing.js';
|
|
8
|
+
export { canonicalBillingAuthority, canonicalBillingTaxQuote } from './billing-authority.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { BillingFinalInvoiceAuthority, BillingTaxQuote } from './billing';
|
|
2
|
+
export declare function canonicalBillingAuthority(authority: Pick<BillingFinalInvoiceAuthority, 'schemaVersion' | 'source' | 'invoice' | 'method'>): string;
|
|
3
|
+
export declare function canonicalBillingTaxQuote(authority: Pick<BillingTaxQuote, 'schemaVersion' | 'source' | 'quote'>): string;
|
package/dist/types/billing.d.ts
CHANGED
|
@@ -84,3 +84,137 @@ export interface BillingPaidInvoice {
|
|
|
84
84
|
paidAt: string;
|
|
85
85
|
observedAt: string;
|
|
86
86
|
}
|
|
87
|
+
/** Provider-independent fiscal evidence. Values come from the configured authority,
|
|
88
|
+
* never from invoice amounts, merchant metadata, or an application tax guess. */
|
|
89
|
+
export interface BillingInvoiceAuthoritySource {
|
|
90
|
+
invoiceId: string;
|
|
91
|
+
paymentIntentId: string;
|
|
92
|
+
customerId: string;
|
|
93
|
+
subscriptionId: string;
|
|
94
|
+
priceId: string;
|
|
95
|
+
planId: string;
|
|
96
|
+
merchantId: string;
|
|
97
|
+
appId: string;
|
|
98
|
+
mode: 'test' | 'live';
|
|
99
|
+
environment: 'development' | 'staging' | 'production';
|
|
100
|
+
}
|
|
101
|
+
export interface BillingFinalInvoice {
|
|
102
|
+
platform: 'peable';
|
|
103
|
+
currency: string;
|
|
104
|
+
grossMinorUnits: number;
|
|
105
|
+
netMinorUnits: number;
|
|
106
|
+
taxMinorUnits: number;
|
|
107
|
+
merchantFeeMinorUnits: number;
|
|
108
|
+
taxTreatment: 'inclusive' | 'exclusive';
|
|
109
|
+
sellerId: string;
|
|
110
|
+
invoiceIssuerId: string;
|
|
111
|
+
taxQuoteId: string;
|
|
112
|
+
customerLocationEvidenceId: string;
|
|
113
|
+
taxRateEvidenceId: string;
|
|
114
|
+
context: {
|
|
115
|
+
payerAccountId: string;
|
|
116
|
+
beneficiaryAccountId: string;
|
|
117
|
+
providerSubscriptionId: string;
|
|
118
|
+
offerId: string;
|
|
119
|
+
offerVersion: number;
|
|
120
|
+
periodStart: string;
|
|
121
|
+
periodEnd: string;
|
|
122
|
+
mode: 'test' | 'live';
|
|
123
|
+
environment: 'development' | 'staging' | 'production';
|
|
124
|
+
};
|
|
125
|
+
issuedAt: string;
|
|
126
|
+
expiresAt: string;
|
|
127
|
+
faircoinQuote?: {
|
|
128
|
+
id: string;
|
|
129
|
+
amountBaseUnits: string;
|
|
130
|
+
quotedAt: string;
|
|
131
|
+
expiresAt: string;
|
|
132
|
+
roundingEvidenceId: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface BillingFinalInvoiceAuthority {
|
|
136
|
+
schemaVersion: 1;
|
|
137
|
+
source: BillingInvoiceAuthoritySource;
|
|
138
|
+
invoice: BillingFinalInvoice;
|
|
139
|
+
method: 'card' | 'faircoin';
|
|
140
|
+
/** Versioned canonical payload: source, invoice and method after strict schema parsing. */
|
|
141
|
+
signature: {
|
|
142
|
+
algorithm: 'Ed25519';
|
|
143
|
+
keyId: string;
|
|
144
|
+
value: string;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** An automatic renewal authorization is an explicit, bounded instruction.
|
|
148
|
+
* Transporting it does not create a mandate or authorize custody of payer keys. */
|
|
149
|
+
export type BillingFaircoinRenewalChoice = {
|
|
150
|
+
method: 'faircoin';
|
|
151
|
+
renewal: 'manual_monthly';
|
|
152
|
+
} | {
|
|
153
|
+
method: 'faircoin';
|
|
154
|
+
renewal: 'automatic';
|
|
155
|
+
consent: BillingFaircoinRenewalConsent;
|
|
156
|
+
};
|
|
157
|
+
export interface BillingFaircoinRenewalConsent {
|
|
158
|
+
authorizationId: string;
|
|
159
|
+
payerAccountId: string;
|
|
160
|
+
merchantId: string;
|
|
161
|
+
appId: string;
|
|
162
|
+
subscriptionId: string;
|
|
163
|
+
planId: string;
|
|
164
|
+
mode: 'test' | 'live';
|
|
165
|
+
environment: 'development' | 'staging' | 'production';
|
|
166
|
+
explicitConsent: true;
|
|
167
|
+
consentEvidenceId: string;
|
|
168
|
+
maximumAmountBaseUnits: string;
|
|
169
|
+
interval: 'month';
|
|
170
|
+
intervalCount: 1;
|
|
171
|
+
startsAt: string;
|
|
172
|
+
expiresAt: string;
|
|
173
|
+
acceptedAt: string;
|
|
174
|
+
}
|
|
175
|
+
export interface BillingFaircoinRenewalRevocation {
|
|
176
|
+
authorizationId: string;
|
|
177
|
+
revokedAt: string;
|
|
178
|
+
revocationEvidenceId: string;
|
|
179
|
+
}
|
|
180
|
+
/** A merchant asks Peable to quote a registered product. Monetary/fiscal
|
|
181
|
+
* configuration is resolved inside Peable, never supplied by a consumer. */
|
|
182
|
+
export interface CreateBillingTaxQuoteParams {
|
|
183
|
+
storeId: string;
|
|
184
|
+
planId: string;
|
|
185
|
+
customerLocationEvidenceId: string;
|
|
186
|
+
}
|
|
187
|
+
export interface BillingTaxQuote {
|
|
188
|
+
schemaVersion: 1;
|
|
189
|
+
source: {
|
|
190
|
+
merchantId: string;
|
|
191
|
+
appId: string;
|
|
192
|
+
storeId: string;
|
|
193
|
+
planId: string;
|
|
194
|
+
mode: 'test' | 'live';
|
|
195
|
+
environment: 'development' | 'staging' | 'production';
|
|
196
|
+
};
|
|
197
|
+
quote: {
|
|
198
|
+
id: string;
|
|
199
|
+
currency: string;
|
|
200
|
+
grossMinorUnits: number;
|
|
201
|
+
netMinorUnits: number;
|
|
202
|
+
taxMinorUnits: number;
|
|
203
|
+
taxTreatment: 'inclusive' | 'exclusive';
|
|
204
|
+
sellerId: string;
|
|
205
|
+
invoiceIssuerId: string;
|
|
206
|
+
taxRemitterId: string;
|
|
207
|
+
taxServiceRef: string;
|
|
208
|
+
country: string;
|
|
209
|
+
coverageEvidenceId: string;
|
|
210
|
+
taxRateEvidenceId: string;
|
|
211
|
+
customerLocationEvidenceId: string;
|
|
212
|
+
quotedAt: string;
|
|
213
|
+
expiresAt: string;
|
|
214
|
+
};
|
|
215
|
+
signature: {
|
|
216
|
+
algorithm: 'Ed25519';
|
|
217
|
+
keyId: string;
|
|
218
|
+
value: string;
|
|
219
|
+
};
|
|
220
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { type MerchantDisplay } from './merchantDisplay';
|
|
|
11
11
|
export { type PaymentLink, type PublicPaymentLink, type CreatePaymentLinkParams, } from './paymentLink';
|
|
12
12
|
export { type CheckoutSession, type CheckoutSessionPublic, type CreateCheckoutSessionParams, } from './checkoutSession';
|
|
13
13
|
export { SOCIAL_SOURCE_APP_MAX_LENGTH, SOCIAL_SOURCE_REF_MAX_LENGTH, type SocialPaymentSource, type SocialNextAddressRequest, type SocialNextAddressResponse, type SocialReceiveCursorResponse, type SocialPaymentDirection, type SocialPayment, type SocialPaymentsResponse, type EnrichmentKind, type EnrichmentResult, type EnrichRequest, type EnrichResponse, } from './social';
|
|
14
|
-
export { BILLING_SUBSCRIPTION_STATUSES, type BillingSubscriptionStatus, type BillingCheckoutSession, type BillingCheckoutObservation, type BillingPaidInvoice, type BillingInvoiceState, type BillingCustomer, type EnsureBillingCustomerParams, type CreateBillingCheckoutParams, type CreateBillingPortalParams, type BillingHostedSession, type BillingSubscription, } from './billing';
|
|
14
|
+
export { BILLING_SUBSCRIPTION_STATUSES, type BillingSubscriptionStatus, type CreateBillingTaxQuoteParams, type BillingTaxQuote, type BillingInvoiceAuthoritySource, type BillingFinalInvoice, type BillingFinalInvoiceAuthority, type BillingFaircoinRenewalChoice, type BillingFaircoinRenewalConsent, type BillingFaircoinRenewalRevocation, type BillingCheckoutSession, type BillingCheckoutObservation, type BillingPaidInvoice, type BillingInvoiceState, type BillingCustomer, type EnsureBillingCustomerParams, type CreateBillingCheckoutParams, type CreateBillingPortalParams, type BillingHostedSession, type BillingSubscription, } from './billing';
|
|
15
|
+
export { canonicalBillingAuthority, canonicalBillingTaxQuote } from './billing-authority';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peable.to/shared-types",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2-oxy-one.0",
|
|
4
4
|
"description": "Shared TypeScript types for the Peable Gateway — the wire contract shared by the backend, SDK, and frontend.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|