@attesso/types 1.0.2 → 1.0.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/README.md +165 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mandate-request.d.ts +96 -0
- package/dist/mandate-request.d.ts.map +1 -0
- package/dist/mandate-request.js +9 -0
- package/dist/mandate-request.js.map +1 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @attesso/types
|
|
2
|
+
|
|
3
|
+
TypeScript type definitions for the Attesso SDK ecosystem.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @attesso/types
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
This package provides shared TypeScript types used across all Attesso packages. It has zero runtime dependencies - types are compile-time only.
|
|
12
|
+
|
|
13
|
+
## Core Types
|
|
14
|
+
|
|
15
|
+
### Mandates
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import type { Mandate, MandateResponse, CreateMandateRequest, MandateStatus } from '@attesso/types';
|
|
19
|
+
|
|
20
|
+
// MandateStatus: 'active' | 'revoked' | 'expired'
|
|
21
|
+
const mandate: MandateResponse = {
|
|
22
|
+
id: 'mandate_xyz',
|
|
23
|
+
botId: 'travel-agent-v1',
|
|
24
|
+
maxAmount: 50000, // cents
|
|
25
|
+
currency: 'USD',
|
|
26
|
+
merchant: 'United Airlines',
|
|
27
|
+
status: 'active',
|
|
28
|
+
createdAt: '2024-01-15T10:00:00Z',
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Payments
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import type {
|
|
36
|
+
Payment,
|
|
37
|
+
PaymentResponse,
|
|
38
|
+
PaymentStatus,
|
|
39
|
+
PaymentErrorCode,
|
|
40
|
+
AuthorizePaymentRequest,
|
|
41
|
+
CapturePaymentRequest,
|
|
42
|
+
CapturePaymentResponse,
|
|
43
|
+
CancelAuthorizationResponse,
|
|
44
|
+
} from '@attesso/types';
|
|
45
|
+
|
|
46
|
+
// PaymentStatus: 'pending' | 'processing' | 'authorized' | 'completed' | 'failed' | 'cancelled'
|
|
47
|
+
// PaymentErrorCode: 'MANDATE_NOT_FOUND' | 'AMOUNT_EXCEEDS_LIMIT' | 'MERCHANT_MISMATCH' | ...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Passports
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import type {
|
|
54
|
+
PassportPayload,
|
|
55
|
+
PassportToken,
|
|
56
|
+
VerifyPassportResult,
|
|
57
|
+
EnhancedPassportPayload,
|
|
58
|
+
PassportReputation,
|
|
59
|
+
ReputationTier,
|
|
60
|
+
} from '@attesso/types';
|
|
61
|
+
|
|
62
|
+
// ReputationTier: 'verified_partner' | 'standard' | 'probationary'
|
|
63
|
+
const passport: PassportPayload = {
|
|
64
|
+
sub: 'user_123',
|
|
65
|
+
bot: 'travel-agent-v1',
|
|
66
|
+
mandate: 'mandate_xyz',
|
|
67
|
+
maxSpend: 50000,
|
|
68
|
+
merchant: 'United Airlines',
|
|
69
|
+
iat: 1705312800,
|
|
70
|
+
exp: 1705316400,
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Users
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import type {
|
|
78
|
+
User,
|
|
79
|
+
BankAccount,
|
|
80
|
+
AuthChallengeRequest,
|
|
81
|
+
AuthChallengeResponse,
|
|
82
|
+
AuthTokenResponse,
|
|
83
|
+
} from '@attesso/types';
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Fee Calculation
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import type {
|
|
90
|
+
RegionalFeeStructure,
|
|
91
|
+
RegionalFees,
|
|
92
|
+
InclusiveFeeConfig,
|
|
93
|
+
FeeBreakdown,
|
|
94
|
+
InclusiveFeeResult,
|
|
95
|
+
} from '@attesso/types';
|
|
96
|
+
|
|
97
|
+
import { STRIPE_REGIONAL_FEES } from '@attesso/types';
|
|
98
|
+
|
|
99
|
+
// Pre-configured regional fees
|
|
100
|
+
console.log(STRIPE_REGIONAL_FEES.EEA); // { variablePercent: 1.5, fixedCents: 25, currency: 'EUR' }
|
|
101
|
+
console.log(STRIPE_REGIONAL_FEES.US); // { variablePercent: 2.9, fixedCents: 30, currency: 'USD' }
|
|
102
|
+
console.log(STRIPE_REGIONAL_FEES.UK); // { variablePercent: 1.5, fixedCents: 20, currency: 'GBP' }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Circuit Breaker Types
|
|
106
|
+
|
|
107
|
+
Types for the bot passport circuit breaker system:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import type {
|
|
111
|
+
CircuitBreakerStatus,
|
|
112
|
+
RevocationReason,
|
|
113
|
+
AnomalyPattern,
|
|
114
|
+
AnomalySeverity,
|
|
115
|
+
PenaltyTier,
|
|
116
|
+
GRLCheckResult,
|
|
117
|
+
AnomalyDetectionResult,
|
|
118
|
+
} from '@attesso/types';
|
|
119
|
+
|
|
120
|
+
import { PENALTY_SCHEDULE, TRIPWIRE_THRESHOLDS } from '@attesso/types';
|
|
121
|
+
|
|
122
|
+
// CircuitBreakerStatus: 'green' | 'yellow' | 'red'
|
|
123
|
+
// AnomalyPattern: 'shotgun' | 'probe' | 'zombie' | 'excessive_errors'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Cloud TEE Types
|
|
127
|
+
|
|
128
|
+
Types for AWS Nitro and GCP Confidential Computing attestation:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import type {
|
|
132
|
+
CloudTEEPlatform,
|
|
133
|
+
NitroAttestationDocument,
|
|
134
|
+
GCPAttestationClaims,
|
|
135
|
+
CloudTEEVerificationResult,
|
|
136
|
+
DeviceAttestation,
|
|
137
|
+
EnclaveImageData,
|
|
138
|
+
FleetMandateRequest,
|
|
139
|
+
} from '@attesso/types';
|
|
140
|
+
|
|
141
|
+
// CloudTEEPlatform: 'aws_nitro' | 'gcp_confidential_vm' | 'gcp_confidential_space'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Package Compatibility
|
|
145
|
+
|
|
146
|
+
This package is used by:
|
|
147
|
+
|
|
148
|
+
- `@attesso/sdk` - Client SDK
|
|
149
|
+
- `@attesso/gatekeeper` - Server-side verification
|
|
150
|
+
- `@attesso/rails` - Payment processing
|
|
151
|
+
- `@attesso/react-native-sdk` - Mobile SDK
|
|
152
|
+
- `vercel-ai-attesso` - Vercel AI SDK integration
|
|
153
|
+
|
|
154
|
+
## Requirements
|
|
155
|
+
|
|
156
|
+
- TypeScript 5.0+
|
|
157
|
+
|
|
158
|
+
## Links
|
|
159
|
+
|
|
160
|
+
- Website: https://www.attesso.com
|
|
161
|
+
- Support: info@attesso.com
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./enclave.js"), exports);
|
|
18
18
|
__exportStar(require("./mandate.js"), exports);
|
|
19
|
+
__exportStar(require("./mandate-request.js"), exports);
|
|
19
20
|
__exportStar(require("./passport.js"), exports);
|
|
20
21
|
__exportStar(require("./payment.js"), exports);
|
|
21
22
|
__exportStar(require("./user.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,gDAA8B;AAC9B,+CAA6B;AAC7B,4CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,gDAA8B;AAC9B,+CAA6B;AAC7B,4CAA0B"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mandate Request Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the asynchronous mandate request flow where agents
|
|
5
|
+
* create requests and users approve via link.
|
|
6
|
+
*/
|
|
7
|
+
export type MandateRequestStatus = 'pending' | 'approved' | 'expired' | 'rejected' | 'cancelled';
|
|
8
|
+
/**
|
|
9
|
+
* Request body for creating a mandate request.
|
|
10
|
+
*/
|
|
11
|
+
export interface CreateMandateRequestInput {
|
|
12
|
+
/** Maximum spend in cents */
|
|
13
|
+
maxAmount: number;
|
|
14
|
+
/** ISO 4217 currency code (default: "USD") */
|
|
15
|
+
currency?: string;
|
|
16
|
+
/** Category for the spending (e.g., "travel", "shopping") */
|
|
17
|
+
category?: string;
|
|
18
|
+
/** Restrict to specific merchant */
|
|
19
|
+
merchant?: string;
|
|
20
|
+
/** Duration the mandate is valid after approval (e.g., "24h", "7d") */
|
|
21
|
+
validityWindow: string;
|
|
22
|
+
/** How long before the approval link expires (default: "1h") */
|
|
23
|
+
requestExpiresIn?: string;
|
|
24
|
+
/** Webhook URL to notify when status changes */
|
|
25
|
+
callbackUrl?: string;
|
|
26
|
+
/** Pass-through metadata */
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Response from creating a mandate request.
|
|
31
|
+
*/
|
|
32
|
+
export interface CreateMandateRequestResponse {
|
|
33
|
+
/** Unique request ID */
|
|
34
|
+
id: string;
|
|
35
|
+
/** URL to send to the user for approval */
|
|
36
|
+
approvalUrl: string;
|
|
37
|
+
/** When the approval link expires */
|
|
38
|
+
expiresAt: string;
|
|
39
|
+
/** Current status */
|
|
40
|
+
status: MandateRequestStatus;
|
|
41
|
+
/** Secret for verifying webhook payloads (only returned on creation) */
|
|
42
|
+
callbackSecret?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mandate details included when a request is approved.
|
|
46
|
+
*/
|
|
47
|
+
export interface ApprovedMandateDetails {
|
|
48
|
+
id: string;
|
|
49
|
+
maxAmount: number;
|
|
50
|
+
currency: string;
|
|
51
|
+
merchant: string | null;
|
|
52
|
+
expiresAt: string | null;
|
|
53
|
+
status: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Full mandate request details when polling.
|
|
57
|
+
*/
|
|
58
|
+
export interface MandateRequestDetails {
|
|
59
|
+
id: string;
|
|
60
|
+
status: MandateRequestStatus;
|
|
61
|
+
maxAmount: number;
|
|
62
|
+
currency: string;
|
|
63
|
+
category: string | null;
|
|
64
|
+
merchant: string | null;
|
|
65
|
+
validityWindow: string;
|
|
66
|
+
expiresAt: string;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
approvedAt?: string;
|
|
69
|
+
rejectedAt?: string;
|
|
70
|
+
metadata: Record<string, unknown> | null;
|
|
71
|
+
/** Mandate details if approved */
|
|
72
|
+
mandate?: ApprovedMandateDetails;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Webhook event types for mandate requests.
|
|
76
|
+
*/
|
|
77
|
+
export type MandateRequestEventType = 'mandate_request.approved' | 'mandate_request.rejected' | 'mandate_request.expired' | 'mandate_request.cancelled';
|
|
78
|
+
/**
|
|
79
|
+
* Webhook payload for mandate request events.
|
|
80
|
+
*/
|
|
81
|
+
export interface MandateRequestWebhookPayload {
|
|
82
|
+
event: MandateRequestEventType;
|
|
83
|
+
timestamp: string;
|
|
84
|
+
data: {
|
|
85
|
+
requestId: string;
|
|
86
|
+
mandateId?: string;
|
|
87
|
+
status: string;
|
|
88
|
+
maxAmount: number;
|
|
89
|
+
currency: string;
|
|
90
|
+
category?: string;
|
|
91
|
+
merchant?: string;
|
|
92
|
+
expiresAt?: string;
|
|
93
|
+
metadata?: unknown;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=mandate-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mandate-request.d.ts","sourceRoot":"","sources":["../src/mandate-request.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,WAAW,CAAC,EA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,0BAA0B,GAC1B,yBAAyB,GACzB,2BAA2B,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,uBAAuB,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mandate Request Types
|
|
4
|
+
*
|
|
5
|
+
* Types for the asynchronous mandate request flow where agents
|
|
6
|
+
* create requests and users approve via link.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=mandate-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mandate-request.js","sourceRoot":"","sources":["../src/mandate-request.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|