@getpara/shared 1.24.0 → 1.26.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/index.js +2 -0
- package/dist/cjs/schemas/permissionsV2.js +188 -0
- package/dist/cjs/types/assets.js +18 -2
- package/dist/cjs/types/auth.js +4 -0
- package/dist/cjs/types/headlessOnRamp.js +9 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/types/permissions.js +2 -0
- package/dist/cjs/types/sdkCapabilities.js +45 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/schemas/permissionsV2.js +185 -0
- package/dist/esm/types/assets.js +17 -1
- package/dist/esm/types/auth.js +4 -0
- package/dist/esm/types/headlessOnRamp.js +8 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/permissions.js +1 -0
- package/dist/esm/types/sdkCapabilities.js +40 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/schemas/permissionsV2.d.ts +1642 -0
- package/dist/types/schemas/permissionsV2.d.ts.map +1 -0
- package/dist/types/types/assets.d.ts +69 -2
- package/dist/types/types/assets.d.ts.map +1 -1
- package/dist/types/types/auth.d.ts +2 -2
- package/dist/types/types/auth.d.ts.map +1 -1
- package/dist/types/types/authState.d.ts +80 -0
- package/dist/types/types/authState.d.ts.map +1 -1
- package/dist/types/types/headlessOnRamp.d.ts +41 -0
- package/dist/types/types/headlessOnRamp.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/partner.d.ts +4 -1
- package/dist/types/types/partner.d.ts.map +1 -1
- package/dist/types/types/permissions.d.ts +96 -0
- package/dist/types/types/permissions.d.ts.map +1 -0
- package/dist/types/types/sdkCapabilities.d.ts +13 -0
- package/dist/types/types/sdkCapabilities.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/cjs/index.js
CHANGED
|
@@ -38,6 +38,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.transactionTypes = void 0;
|
|
40
40
|
__exportStar(require("./types/index.js"), exports);
|
|
41
|
+
__exportStar(require("./types/permissions.js"), exports);
|
|
42
|
+
__exportStar(require("./schemas/permissionsV2.js"), exports);
|
|
41
43
|
__exportStar(require("./utils/index.js"), exports);
|
|
42
44
|
const transactionTypes = __importStar(require("./types/transaction.js"));
|
|
43
45
|
exports.transactionTypes = transactionTypes;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissionsV2ValidationErrorSchema = exports.permissionsV2DelegationConsentDiscoveryResponseSchema = exports.permissionsV2DelegationConsentRequestSchema = exports.permissionsV2DelegationConsentViewSchema = exports.permissionsV2DelegationConsentStandingMutationSchema = exports.permissionsV2DelegationConsentMutationSchema = exports.permissionsV2DelegationConsentApiStatusSchema = exports.permissionsV2DelegationPolicyDefinitionSchema = exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema = exports.permissionsV2PartnerPolicyCandidateSchema = exports.permissionsV2PolicyRuleSchema = exports.permissionsV2PartnerPolicyMetadataSchema = exports.permissionsV2PolicyMetadataSchema = exports.permissionsV2PartnerAuthoredPolicySelectorSchema = exports.permissionsV2ConditionSchema = exports.policyAuthoringJsonObjectSchema = exports.policyAuthoringJsonValueSchema = exports.policyAuthoringJsonPrimitiveSchema = exports.permissionsV2SigningRequestTypeSchema = exports.permissionsV2SigningRequestRouteSchema = exports.permissionsV2SigningWalletTypeSchema = exports.permissionsV2AggregateOperatorSchema = exports.permissionsV2CompareOperatorSchema = exports.permissionsV2PolicyEffectSchema = exports.permissionsV2PolicyModeSchema = exports.permissionsV2PolicyLayerSchema = exports.permissionsV2SigningRequestTypes = exports.policyAuthoringSigningRequestRoutes = exports.policyAuthoringSigningWalletTypes = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.policyAuthoringSigningWalletTypes = ['EVM'];
|
|
6
|
+
exports.policyAuthoringSigningRequestRoutes = [
|
|
7
|
+
'evm.sign_transaction',
|
|
8
|
+
'evm.sign_raw',
|
|
9
|
+
'evm.sign_typed_data',
|
|
10
|
+
'evm.sign_authorization',
|
|
11
|
+
'evm.sign_message',
|
|
12
|
+
'smart_account.user_operation',
|
|
13
|
+
];
|
|
14
|
+
exports.permissionsV2SigningRequestTypes = [
|
|
15
|
+
'evm_transaction',
|
|
16
|
+
'evm_message',
|
|
17
|
+
'evm_raw',
|
|
18
|
+
'evm_typed_data',
|
|
19
|
+
'evm_authorization',
|
|
20
|
+
'smart_account_user_operation',
|
|
21
|
+
];
|
|
22
|
+
const nonEmptyStringSchema = zod_1.z.string().min(1);
|
|
23
|
+
const uniqueNonEmptyStringsSchema = zod_1.z
|
|
24
|
+
.array(nonEmptyStringSchema)
|
|
25
|
+
.min(1)
|
|
26
|
+
.refine((values) => new Set(values).size === values.length, 'values must be unique');
|
|
27
|
+
exports.permissionsV2PolicyLayerSchema = zod_1.z.enum(['para', 'partner']);
|
|
28
|
+
exports.permissionsV2PolicyModeSchema = zod_1.z.enum(['guardrail', 'delegation']);
|
|
29
|
+
exports.permissionsV2PolicyEffectSchema = zod_1.z.enum(['allow', 'deny', 'require_approval']);
|
|
30
|
+
exports.permissionsV2CompareOperatorSchema = zod_1.z.enum(['eq', 'ne', 'lt', 'lte', 'gt', 'gte', 'in']);
|
|
31
|
+
exports.permissionsV2AggregateOperatorSchema = zod_1.z.enum(['lt', 'lte', 'gt', 'gte']);
|
|
32
|
+
exports.permissionsV2SigningWalletTypeSchema = zod_1.z.enum(exports.policyAuthoringSigningWalletTypes);
|
|
33
|
+
exports.permissionsV2SigningRequestRouteSchema = zod_1.z.enum(exports.policyAuthoringSigningRequestRoutes);
|
|
34
|
+
exports.permissionsV2SigningRequestTypeSchema = zod_1.z.enum(exports.permissionsV2SigningRequestTypes);
|
|
35
|
+
exports.policyAuthoringJsonPrimitiveSchema = zod_1.z.union([
|
|
36
|
+
zod_1.z.string(),
|
|
37
|
+
zod_1.z.number(),
|
|
38
|
+
zod_1.z.boolean(),
|
|
39
|
+
zod_1.z.null(),
|
|
40
|
+
]);
|
|
41
|
+
exports.policyAuthoringJsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
42
|
+
exports.policyAuthoringJsonPrimitiveSchema,
|
|
43
|
+
zod_1.z.array(exports.policyAuthoringJsonValueSchema),
|
|
44
|
+
zod_1.z.record(exports.policyAuthoringJsonValueSchema),
|
|
45
|
+
]));
|
|
46
|
+
exports.policyAuthoringJsonObjectSchema = zod_1.z.record(exports.policyAuthoringJsonValueSchema);
|
|
47
|
+
exports.permissionsV2ConditionSchema = zod_1.z.lazy(() => zod_1.z.discriminatedUnion('kind', [
|
|
48
|
+
zod_1.z
|
|
49
|
+
.object({
|
|
50
|
+
kind: zod_1.z.literal('compare'),
|
|
51
|
+
fact: nonEmptyStringSchema,
|
|
52
|
+
op: exports.permissionsV2CompareOperatorSchema,
|
|
53
|
+
value: exports.policyAuthoringJsonValueSchema,
|
|
54
|
+
})
|
|
55
|
+
.strict(),
|
|
56
|
+
zod_1.z
|
|
57
|
+
.object({
|
|
58
|
+
kind: zod_1.z.literal('aggregate'),
|
|
59
|
+
fact: nonEmptyStringSchema,
|
|
60
|
+
op: exports.permissionsV2AggregateOperatorSchema,
|
|
61
|
+
value: nonEmptyStringSchema,
|
|
62
|
+
window: nonEmptyStringSchema,
|
|
63
|
+
asset: nonEmptyStringSchema.optional(),
|
|
64
|
+
})
|
|
65
|
+
.strict(),
|
|
66
|
+
zod_1.z
|
|
67
|
+
.object({
|
|
68
|
+
kind: zod_1.z.literal('all'),
|
|
69
|
+
of: zod_1.z.array(exports.permissionsV2ConditionSchema).min(1),
|
|
70
|
+
})
|
|
71
|
+
.strict(),
|
|
72
|
+
zod_1.z
|
|
73
|
+
.object({
|
|
74
|
+
kind: zod_1.z.literal('any'),
|
|
75
|
+
of: zod_1.z.array(exports.permissionsV2ConditionSchema).min(1),
|
|
76
|
+
})
|
|
77
|
+
.strict(),
|
|
78
|
+
zod_1.z
|
|
79
|
+
.object({
|
|
80
|
+
kind: zod_1.z.literal('not'),
|
|
81
|
+
of: exports.permissionsV2ConditionSchema,
|
|
82
|
+
})
|
|
83
|
+
.strict(),
|
|
84
|
+
]));
|
|
85
|
+
exports.permissionsV2PartnerAuthoredPolicySelectorSchema = zod_1.z
|
|
86
|
+
.object({
|
|
87
|
+
walletId: nonEmptyStringSchema.optional(),
|
|
88
|
+
chainId: zod_1.z.union([nonEmptyStringSchema, uniqueNonEmptyStringsSchema]).optional(),
|
|
89
|
+
walletType: exports.permissionsV2SigningWalletTypeSchema.optional(),
|
|
90
|
+
requestRoute: exports.permissionsV2SigningRequestRouteSchema.optional(),
|
|
91
|
+
requestType: exports.permissionsV2SigningRequestTypeSchema.optional(),
|
|
92
|
+
})
|
|
93
|
+
.strict();
|
|
94
|
+
exports.permissionsV2PolicyMetadataSchema = zod_1.z
|
|
95
|
+
.object({
|
|
96
|
+
label: zod_1.z.string().optional(),
|
|
97
|
+
productMode: exports.permissionsV2PolicyModeSchema.optional(),
|
|
98
|
+
description: zod_1.z.string().optional(),
|
|
99
|
+
annotations: exports.policyAuthoringJsonObjectSchema.optional(),
|
|
100
|
+
})
|
|
101
|
+
.strict();
|
|
102
|
+
exports.permissionsV2PartnerPolicyMetadataSchema = exports.permissionsV2PolicyMetadataSchema.extend({
|
|
103
|
+
productMode: exports.permissionsV2PolicyModeSchema,
|
|
104
|
+
});
|
|
105
|
+
exports.permissionsV2PolicyRuleSchema = zod_1.z
|
|
106
|
+
.object({
|
|
107
|
+
id: nonEmptyStringSchema,
|
|
108
|
+
effect: exports.permissionsV2PolicyEffectSchema,
|
|
109
|
+
when: exports.permissionsV2ConditionSchema,
|
|
110
|
+
})
|
|
111
|
+
.strict();
|
|
112
|
+
const partnerPolicyCandidateFields = {
|
|
113
|
+
id: nonEmptyStringSchema,
|
|
114
|
+
schemaVersion: zod_1.z.literal('permissions.policy.v1'),
|
|
115
|
+
version: nonEmptyStringSchema,
|
|
116
|
+
selector: exports.permissionsV2PartnerAuthoredPolicySelectorSchema,
|
|
117
|
+
rules: zod_1.z.array(exports.permissionsV2PolicyRuleSchema).min(1),
|
|
118
|
+
metadata: exports.permissionsV2PolicyMetadataSchema.optional(),
|
|
119
|
+
};
|
|
120
|
+
exports.permissionsV2PartnerPolicyCandidateSchema = zod_1.z.object(partnerPolicyCandidateFields).strict();
|
|
121
|
+
exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema = exports.permissionsV2PartnerPolicyCandidateSchema.extend({
|
|
122
|
+
metadata: exports.permissionsV2PartnerPolicyMetadataSchema,
|
|
123
|
+
});
|
|
124
|
+
exports.permissionsV2DelegationPolicyDefinitionSchema = exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema.extend({
|
|
125
|
+
layer: zod_1.z.literal('partner'),
|
|
126
|
+
selector: exports.permissionsV2PartnerAuthoredPolicySelectorSchema.extend({
|
|
127
|
+
partnerId: nonEmptyStringSchema,
|
|
128
|
+
appId: nonEmptyStringSchema,
|
|
129
|
+
}),
|
|
130
|
+
metadata: exports.permissionsV2PartnerPolicyMetadataSchema.extend({
|
|
131
|
+
productMode: zod_1.z.literal('delegation'),
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
exports.permissionsV2DelegationConsentApiStatusSchema = zod_1.z.enum([
|
|
135
|
+
'pending',
|
|
136
|
+
'standing',
|
|
137
|
+
'manual_review',
|
|
138
|
+
'revoked',
|
|
139
|
+
'expired',
|
|
140
|
+
]);
|
|
141
|
+
exports.permissionsV2DelegationConsentMutationSchema = zod_1.z
|
|
142
|
+
.object({
|
|
143
|
+
partnerId: nonEmptyStringSchema,
|
|
144
|
+
appId: nonEmptyStringSchema,
|
|
145
|
+
walletId: nonEmptyStringSchema,
|
|
146
|
+
policyVersion: nonEmptyStringSchema,
|
|
147
|
+
policyHash: nonEmptyStringSchema,
|
|
148
|
+
expiresAt: zod_1.z.string().datetime().optional(),
|
|
149
|
+
})
|
|
150
|
+
.strict();
|
|
151
|
+
exports.permissionsV2DelegationConsentStandingMutationSchema = exports.permissionsV2DelegationConsentMutationSchema
|
|
152
|
+
.extend({
|
|
153
|
+
pendingTransactionId: nonEmptyStringSchema,
|
|
154
|
+
})
|
|
155
|
+
.strict();
|
|
156
|
+
exports.permissionsV2DelegationConsentViewSchema = zod_1.z
|
|
157
|
+
.object({
|
|
158
|
+
status: exports.permissionsV2DelegationConsentApiStatusSchema,
|
|
159
|
+
userId: nonEmptyStringSchema,
|
|
160
|
+
partnerId: nonEmptyStringSchema,
|
|
161
|
+
appId: nonEmptyStringSchema,
|
|
162
|
+
walletId: nonEmptyStringSchema,
|
|
163
|
+
policyId: nonEmptyStringSchema,
|
|
164
|
+
policyVersion: nonEmptyStringSchema,
|
|
165
|
+
policyHash: nonEmptyStringSchema,
|
|
166
|
+
grantedAt: zod_1.z.string().datetime().optional(),
|
|
167
|
+
expiresAt: zod_1.z.string().datetime().optional(),
|
|
168
|
+
revokedAt: zod_1.z.string().datetime().optional(),
|
|
169
|
+
})
|
|
170
|
+
.strict();
|
|
171
|
+
exports.permissionsV2DelegationConsentRequestSchema = zod_1.z
|
|
172
|
+
.object({
|
|
173
|
+
policy: exports.permissionsV2DelegationPolicyDefinitionSchema,
|
|
174
|
+
consent: exports.permissionsV2DelegationConsentViewSchema,
|
|
175
|
+
})
|
|
176
|
+
.strict();
|
|
177
|
+
exports.permissionsV2DelegationConsentDiscoveryResponseSchema = zod_1.z
|
|
178
|
+
.object({
|
|
179
|
+
requests: zod_1.z.array(exports.permissionsV2DelegationConsentRequestSchema),
|
|
180
|
+
})
|
|
181
|
+
.strict();
|
|
182
|
+
exports.permissionsV2ValidationErrorSchema = zod_1.z
|
|
183
|
+
.object({
|
|
184
|
+
code: zod_1.z.string(),
|
|
185
|
+
path: zod_1.z.string(),
|
|
186
|
+
message: zod_1.z.string(),
|
|
187
|
+
})
|
|
188
|
+
.strict();
|
package/dist/cjs/types/assets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OnRampMethod = exports.OnRampPurchaseStatus = exports.OnRampPurchaseType = exports.ON_RAMP_ASSETS = exports.OnRampAsset = exports.ON_RAMP_PROVIDERS = exports.OnRampProvider = void 0;
|
|
3
|
+
exports.OnRampMethod = exports.OnRampPurchaseStatus = exports.OnRampPurchaseType = exports.ON_RAMP_ASSETS = exports.OnRampAsset = exports.PROVIDER_PAYMENT_METHODS = exports.ON_RAMP_PAYMENT_METHODS = exports.ON_RAMP_PROVIDERS = exports.OnRampProvider = void 0;
|
|
4
4
|
/** @deprecated use `OnRampProvider` string union instead */
|
|
5
5
|
var OnRampProvider;
|
|
6
6
|
(function (OnRampProvider) {
|
|
@@ -9,8 +9,24 @@ var OnRampProvider;
|
|
|
9
9
|
OnRampProvider["MOONPAY"] = "MOONPAY";
|
|
10
10
|
OnRampProvider["CDP"] = "CDP";
|
|
11
11
|
OnRampProvider["MERCURYO"] = "MERCURYO";
|
|
12
|
+
OnRampProvider["BRALE"] = "BRALE";
|
|
12
13
|
})(OnRampProvider || (exports.OnRampProvider = OnRampProvider = {}));
|
|
13
|
-
exports.ON_RAMP_PROVIDERS = ['RAMP', 'STRIPE', 'MOONPAY', 'CDP', 'MERCURYO'];
|
|
14
|
+
exports.ON_RAMP_PROVIDERS = ['RAMP', 'STRIPE', 'MOONPAY', 'CDP', 'MERCURYO', 'BRALE'];
|
|
15
|
+
// Payment flows a provider can offer for an implementation in the request's region. Drives which
|
|
16
|
+
// call-to-action the AddFunds modal renders. WIDGET = the hosted redirect flow (provider selection +
|
|
17
|
+
// Continue) that every widget provider supports; APPLE_PAY / CARD / BANK are headless flows enabled
|
|
18
|
+
// per integration.
|
|
19
|
+
exports.ON_RAMP_PAYMENT_METHODS = ['APPLE_PAY', 'CARD', 'BANK', 'WIDGET'];
|
|
20
|
+
// Provider -> the payment flows it can offer, independent of geo. The catalog resolver intersects this
|
|
21
|
+
// with per-region provider availability so a provider only appears (with its methods) where it's buyable.
|
|
22
|
+
exports.PROVIDER_PAYMENT_METHODS = {
|
|
23
|
+
RAMP: ['WIDGET'],
|
|
24
|
+
STRIPE: ['WIDGET'],
|
|
25
|
+
MOONPAY: ['WIDGET', 'CARD'],
|
|
26
|
+
CDP: ['WIDGET', 'APPLE_PAY'],
|
|
27
|
+
MERCURYO: ['WIDGET', 'APPLE_PAY'],
|
|
28
|
+
BRALE: ['BANK'],
|
|
29
|
+
};
|
|
14
30
|
/** @deprecated use `TOnRampAsset` string union instead */
|
|
15
31
|
var OnRampAsset;
|
|
16
32
|
(function (OnRampAsset) {
|
package/dist/cjs/types/auth.js
CHANGED
|
@@ -57,6 +57,10 @@ exports.OAUTH_METHODS = [
|
|
|
57
57
|
'FARCASTER',
|
|
58
58
|
'TELEGRAM',
|
|
59
59
|
'CUSTOM_OIDC',
|
|
60
|
+
// A partner-configured OAuth2 provider Para ships no first-party adapter for (e.g. Spotify). The specific
|
|
61
|
+
// connection rides on the flow's providerConfigHandle; the generic OAuth2 client uses the connection's
|
|
62
|
+
// stored endpoints. (ENG-7008)
|
|
63
|
+
'CUSTOM_OAUTH',
|
|
60
64
|
];
|
|
61
65
|
exports.LINKED_ACCOUNT_TYPES = [
|
|
62
66
|
'EMAIL',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Headless on-ramp types, shared between the server and the web-sdk client so request/response shapes
|
|
3
|
+
// aren't duplicated across the server and the user-management-client.
|
|
4
|
+
//
|
|
5
|
+
// Each headless (native Apple Pay / Platform SDK) provider has its own router and route per action —
|
|
6
|
+
// POST /users/:userId/onramp/<provider>/<action> — with its param/result types defined below. CDP
|
|
7
|
+
// (Coinbase) is the only provider defined + wired today; Mercuryo and MoonPay add their types here when
|
|
8
|
+
// they land on their own branches.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -16,14 +16,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./assets.js"), exports);
|
|
18
18
|
__exportStar(require("./auth.js"), exports);
|
|
19
|
+
__exportStar(require("./headlessOnRamp.js"), exports);
|
|
19
20
|
__exportStar(require("./authFactor.js"), exports);
|
|
20
21
|
__exportStar(require("./authState.js"), exports);
|
|
21
22
|
__exportStar(require("./modal.js"), exports);
|
|
22
23
|
__exportStar(require("./otp.js"), exports);
|
|
23
24
|
__exportStar(require("./params.js"), exports);
|
|
24
25
|
__exportStar(require("./partner.js"), exports);
|
|
26
|
+
__exportStar(require("./sdkCapabilities.js"), exports);
|
|
25
27
|
__exportStar(require("./partnerAppConfig.js"), exports);
|
|
26
28
|
__exportStar(require("./pending-transaction.js"), exports);
|
|
29
|
+
__exportStar(require("./permissions.js"), exports);
|
|
27
30
|
__exportStar(require("./signing.js"), exports);
|
|
28
31
|
__exportStar(require("./theme.js"), exports);
|
|
29
32
|
__exportStar(require("./transaction.js"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Client → server capability negotiation.
|
|
3
|
+
//
|
|
4
|
+
// The SDK advertises which features THIS build supports via a single request header, and the server gates
|
|
5
|
+
// behavior on the presence of a token rather than on an SDK version number. This keeps a capability coupled
|
|
6
|
+
// to the build that implements it (no cross-repo version guessing) and, unlike a header-per-feature, needs
|
|
7
|
+
// only ONE CORS `allowedHeaders` + `Vary` entry no matter how many capabilities are added.
|
|
8
|
+
//
|
|
9
|
+
// To add a capability: add a token below, send it from the SDK build that implements it
|
|
10
|
+
// (`serializeCapabilities`), and check for it on the server (`parseCapabilities(...).has(...)`).
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SdkCapability = exports.SDK_CAPABILITIES_HEADER = void 0;
|
|
13
|
+
exports.serializeCapabilities = serializeCapabilities;
|
|
14
|
+
exports.parseCapabilities = parseCapabilities;
|
|
15
|
+
exports.SDK_CAPABILITIES_HEADER = 'x-para-capabilities';
|
|
16
|
+
var SdkCapability;
|
|
17
|
+
(function (SdkCapability) {
|
|
18
|
+
// The build ships the on-ramp catalog picker, so it wants the OnRampConfigV2 (DB-reference) config shape
|
|
19
|
+
// from GET /on-ramp-config instead of the legacy assetInfo config. Checked server-side in onRampConfig.ts.
|
|
20
|
+
SdkCapability["OnRampCatalog"] = "onramp-catalog";
|
|
21
|
+
// The build can drive the Coinbase (CDP) headless on-ramp order flow. Advertised by the SDK now, but NOT
|
|
22
|
+
// yet gated server-side — the CDP order route serves everyone; wire a parseCapabilities(...).has(...) check
|
|
23
|
+
// here when the flow needs to condition on client support.
|
|
24
|
+
SdkCapability["CdpHeadless"] = "cdp-headless";
|
|
25
|
+
})(SdkCapability || (exports.SdkCapability = SdkCapability = {}));
|
|
26
|
+
const KNOWN_CAPABILITIES = new Set(Object.values(SdkCapability));
|
|
27
|
+
/** Serialize a build's supported capabilities into the header value (comma-separated tokens). */
|
|
28
|
+
function serializeCapabilities(capabilities) {
|
|
29
|
+
return [...new Set(capabilities)].join(',');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parse the capabilities header into the set of KNOWN capabilities the client advertised. Unknown tokens
|
|
33
|
+
* (e.g. a newer SDK advertising a capability this server doesn't understand yet) are ignored.
|
|
34
|
+
*/
|
|
35
|
+
function parseCapabilities(header) {
|
|
36
|
+
const result = new Set();
|
|
37
|
+
if (!header)
|
|
38
|
+
return result;
|
|
39
|
+
for (const raw of header.split(',')) {
|
|
40
|
+
const token = raw.trim();
|
|
41
|
+
if (KNOWN_CAPABILITIES.has(token))
|
|
42
|
+
result.add(token);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const policyAuthoringSigningWalletTypes = ['EVM'];
|
|
3
|
+
export const policyAuthoringSigningRequestRoutes = [
|
|
4
|
+
'evm.sign_transaction',
|
|
5
|
+
'evm.sign_raw',
|
|
6
|
+
'evm.sign_typed_data',
|
|
7
|
+
'evm.sign_authorization',
|
|
8
|
+
'evm.sign_message',
|
|
9
|
+
'smart_account.user_operation',
|
|
10
|
+
];
|
|
11
|
+
export const permissionsV2SigningRequestTypes = [
|
|
12
|
+
'evm_transaction',
|
|
13
|
+
'evm_message',
|
|
14
|
+
'evm_raw',
|
|
15
|
+
'evm_typed_data',
|
|
16
|
+
'evm_authorization',
|
|
17
|
+
'smart_account_user_operation',
|
|
18
|
+
];
|
|
19
|
+
const nonEmptyStringSchema = z.string().min(1);
|
|
20
|
+
const uniqueNonEmptyStringsSchema = z
|
|
21
|
+
.array(nonEmptyStringSchema)
|
|
22
|
+
.min(1)
|
|
23
|
+
.refine((values) => new Set(values).size === values.length, 'values must be unique');
|
|
24
|
+
export const permissionsV2PolicyLayerSchema = z.enum(['para', 'partner']);
|
|
25
|
+
export const permissionsV2PolicyModeSchema = z.enum(['guardrail', 'delegation']);
|
|
26
|
+
export const permissionsV2PolicyEffectSchema = z.enum(['allow', 'deny', 'require_approval']);
|
|
27
|
+
export const permissionsV2CompareOperatorSchema = z.enum(['eq', 'ne', 'lt', 'lte', 'gt', 'gte', 'in']);
|
|
28
|
+
export const permissionsV2AggregateOperatorSchema = z.enum(['lt', 'lte', 'gt', 'gte']);
|
|
29
|
+
export const permissionsV2SigningWalletTypeSchema = z.enum(policyAuthoringSigningWalletTypes);
|
|
30
|
+
export const permissionsV2SigningRequestRouteSchema = z.enum(policyAuthoringSigningRequestRoutes);
|
|
31
|
+
export const permissionsV2SigningRequestTypeSchema = z.enum(permissionsV2SigningRequestTypes);
|
|
32
|
+
export const policyAuthoringJsonPrimitiveSchema = z.union([
|
|
33
|
+
z.string(),
|
|
34
|
+
z.number(),
|
|
35
|
+
z.boolean(),
|
|
36
|
+
z.null(),
|
|
37
|
+
]);
|
|
38
|
+
export const policyAuthoringJsonValueSchema = z.lazy(() => z.union([
|
|
39
|
+
policyAuthoringJsonPrimitiveSchema,
|
|
40
|
+
z.array(policyAuthoringJsonValueSchema),
|
|
41
|
+
z.record(policyAuthoringJsonValueSchema),
|
|
42
|
+
]));
|
|
43
|
+
export const policyAuthoringJsonObjectSchema = z.record(policyAuthoringJsonValueSchema);
|
|
44
|
+
export const permissionsV2ConditionSchema = z.lazy(() => z.discriminatedUnion('kind', [
|
|
45
|
+
z
|
|
46
|
+
.object({
|
|
47
|
+
kind: z.literal('compare'),
|
|
48
|
+
fact: nonEmptyStringSchema,
|
|
49
|
+
op: permissionsV2CompareOperatorSchema,
|
|
50
|
+
value: policyAuthoringJsonValueSchema,
|
|
51
|
+
})
|
|
52
|
+
.strict(),
|
|
53
|
+
z
|
|
54
|
+
.object({
|
|
55
|
+
kind: z.literal('aggregate'),
|
|
56
|
+
fact: nonEmptyStringSchema,
|
|
57
|
+
op: permissionsV2AggregateOperatorSchema,
|
|
58
|
+
value: nonEmptyStringSchema,
|
|
59
|
+
window: nonEmptyStringSchema,
|
|
60
|
+
asset: nonEmptyStringSchema.optional(),
|
|
61
|
+
})
|
|
62
|
+
.strict(),
|
|
63
|
+
z
|
|
64
|
+
.object({
|
|
65
|
+
kind: z.literal('all'),
|
|
66
|
+
of: z.array(permissionsV2ConditionSchema).min(1),
|
|
67
|
+
})
|
|
68
|
+
.strict(),
|
|
69
|
+
z
|
|
70
|
+
.object({
|
|
71
|
+
kind: z.literal('any'),
|
|
72
|
+
of: z.array(permissionsV2ConditionSchema).min(1),
|
|
73
|
+
})
|
|
74
|
+
.strict(),
|
|
75
|
+
z
|
|
76
|
+
.object({
|
|
77
|
+
kind: z.literal('not'),
|
|
78
|
+
of: permissionsV2ConditionSchema,
|
|
79
|
+
})
|
|
80
|
+
.strict(),
|
|
81
|
+
]));
|
|
82
|
+
export const permissionsV2PartnerAuthoredPolicySelectorSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
walletId: nonEmptyStringSchema.optional(),
|
|
85
|
+
chainId: z.union([nonEmptyStringSchema, uniqueNonEmptyStringsSchema]).optional(),
|
|
86
|
+
walletType: permissionsV2SigningWalletTypeSchema.optional(),
|
|
87
|
+
requestRoute: permissionsV2SigningRequestRouteSchema.optional(),
|
|
88
|
+
requestType: permissionsV2SigningRequestTypeSchema.optional(),
|
|
89
|
+
})
|
|
90
|
+
.strict();
|
|
91
|
+
export const permissionsV2PolicyMetadataSchema = z
|
|
92
|
+
.object({
|
|
93
|
+
label: z.string().optional(),
|
|
94
|
+
productMode: permissionsV2PolicyModeSchema.optional(),
|
|
95
|
+
description: z.string().optional(),
|
|
96
|
+
annotations: policyAuthoringJsonObjectSchema.optional(),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
export const permissionsV2PartnerPolicyMetadataSchema = permissionsV2PolicyMetadataSchema.extend({
|
|
100
|
+
productMode: permissionsV2PolicyModeSchema,
|
|
101
|
+
});
|
|
102
|
+
export const permissionsV2PolicyRuleSchema = z
|
|
103
|
+
.object({
|
|
104
|
+
id: nonEmptyStringSchema,
|
|
105
|
+
effect: permissionsV2PolicyEffectSchema,
|
|
106
|
+
when: permissionsV2ConditionSchema,
|
|
107
|
+
})
|
|
108
|
+
.strict();
|
|
109
|
+
const partnerPolicyCandidateFields = {
|
|
110
|
+
id: nonEmptyStringSchema,
|
|
111
|
+
schemaVersion: z.literal('permissions.policy.v1'),
|
|
112
|
+
version: nonEmptyStringSchema,
|
|
113
|
+
selector: permissionsV2PartnerAuthoredPolicySelectorSchema,
|
|
114
|
+
rules: z.array(permissionsV2PolicyRuleSchema).min(1),
|
|
115
|
+
metadata: permissionsV2PolicyMetadataSchema.optional(),
|
|
116
|
+
};
|
|
117
|
+
export const permissionsV2PartnerPolicyCandidateSchema = z.object(partnerPolicyCandidateFields).strict();
|
|
118
|
+
export const permissionsV2PartnerAuthoredPolicyDefinitionSchema = permissionsV2PartnerPolicyCandidateSchema.extend({
|
|
119
|
+
metadata: permissionsV2PartnerPolicyMetadataSchema,
|
|
120
|
+
});
|
|
121
|
+
export const permissionsV2DelegationPolicyDefinitionSchema = permissionsV2PartnerAuthoredPolicyDefinitionSchema.extend({
|
|
122
|
+
layer: z.literal('partner'),
|
|
123
|
+
selector: permissionsV2PartnerAuthoredPolicySelectorSchema.extend({
|
|
124
|
+
partnerId: nonEmptyStringSchema,
|
|
125
|
+
appId: nonEmptyStringSchema,
|
|
126
|
+
}),
|
|
127
|
+
metadata: permissionsV2PartnerPolicyMetadataSchema.extend({
|
|
128
|
+
productMode: z.literal('delegation'),
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
export const permissionsV2DelegationConsentApiStatusSchema = z.enum([
|
|
132
|
+
'pending',
|
|
133
|
+
'standing',
|
|
134
|
+
'manual_review',
|
|
135
|
+
'revoked',
|
|
136
|
+
'expired',
|
|
137
|
+
]);
|
|
138
|
+
export const permissionsV2DelegationConsentMutationSchema = z
|
|
139
|
+
.object({
|
|
140
|
+
partnerId: nonEmptyStringSchema,
|
|
141
|
+
appId: nonEmptyStringSchema,
|
|
142
|
+
walletId: nonEmptyStringSchema,
|
|
143
|
+
policyVersion: nonEmptyStringSchema,
|
|
144
|
+
policyHash: nonEmptyStringSchema,
|
|
145
|
+
expiresAt: z.string().datetime().optional(),
|
|
146
|
+
})
|
|
147
|
+
.strict();
|
|
148
|
+
export const permissionsV2DelegationConsentStandingMutationSchema = permissionsV2DelegationConsentMutationSchema
|
|
149
|
+
.extend({
|
|
150
|
+
pendingTransactionId: nonEmptyStringSchema,
|
|
151
|
+
})
|
|
152
|
+
.strict();
|
|
153
|
+
export const permissionsV2DelegationConsentViewSchema = z
|
|
154
|
+
.object({
|
|
155
|
+
status: permissionsV2DelegationConsentApiStatusSchema,
|
|
156
|
+
userId: nonEmptyStringSchema,
|
|
157
|
+
partnerId: nonEmptyStringSchema,
|
|
158
|
+
appId: nonEmptyStringSchema,
|
|
159
|
+
walletId: nonEmptyStringSchema,
|
|
160
|
+
policyId: nonEmptyStringSchema,
|
|
161
|
+
policyVersion: nonEmptyStringSchema,
|
|
162
|
+
policyHash: nonEmptyStringSchema,
|
|
163
|
+
grantedAt: z.string().datetime().optional(),
|
|
164
|
+
expiresAt: z.string().datetime().optional(),
|
|
165
|
+
revokedAt: z.string().datetime().optional(),
|
|
166
|
+
})
|
|
167
|
+
.strict();
|
|
168
|
+
export const permissionsV2DelegationConsentRequestSchema = z
|
|
169
|
+
.object({
|
|
170
|
+
policy: permissionsV2DelegationPolicyDefinitionSchema,
|
|
171
|
+
consent: permissionsV2DelegationConsentViewSchema,
|
|
172
|
+
})
|
|
173
|
+
.strict();
|
|
174
|
+
export const permissionsV2DelegationConsentDiscoveryResponseSchema = z
|
|
175
|
+
.object({
|
|
176
|
+
requests: z.array(permissionsV2DelegationConsentRequestSchema),
|
|
177
|
+
})
|
|
178
|
+
.strict();
|
|
179
|
+
export const permissionsV2ValidationErrorSchema = z
|
|
180
|
+
.object({
|
|
181
|
+
code: z.string(),
|
|
182
|
+
path: z.string(),
|
|
183
|
+
message: z.string(),
|
|
184
|
+
})
|
|
185
|
+
.strict();
|
package/dist/esm/types/assets.js
CHANGED
|
@@ -6,8 +6,24 @@ export var OnRampProvider;
|
|
|
6
6
|
OnRampProvider["MOONPAY"] = "MOONPAY";
|
|
7
7
|
OnRampProvider["CDP"] = "CDP";
|
|
8
8
|
OnRampProvider["MERCURYO"] = "MERCURYO";
|
|
9
|
+
OnRampProvider["BRALE"] = "BRALE";
|
|
9
10
|
})(OnRampProvider || (OnRampProvider = {}));
|
|
10
|
-
export const ON_RAMP_PROVIDERS = ['RAMP', 'STRIPE', 'MOONPAY', 'CDP', 'MERCURYO'];
|
|
11
|
+
export const ON_RAMP_PROVIDERS = ['RAMP', 'STRIPE', 'MOONPAY', 'CDP', 'MERCURYO', 'BRALE'];
|
|
12
|
+
// Payment flows a provider can offer for an implementation in the request's region. Drives which
|
|
13
|
+
// call-to-action the AddFunds modal renders. WIDGET = the hosted redirect flow (provider selection +
|
|
14
|
+
// Continue) that every widget provider supports; APPLE_PAY / CARD / BANK are headless flows enabled
|
|
15
|
+
// per integration.
|
|
16
|
+
export const ON_RAMP_PAYMENT_METHODS = ['APPLE_PAY', 'CARD', 'BANK', 'WIDGET'];
|
|
17
|
+
// Provider -> the payment flows it can offer, independent of geo. The catalog resolver intersects this
|
|
18
|
+
// with per-region provider availability so a provider only appears (with its methods) where it's buyable.
|
|
19
|
+
export const PROVIDER_PAYMENT_METHODS = {
|
|
20
|
+
RAMP: ['WIDGET'],
|
|
21
|
+
STRIPE: ['WIDGET'],
|
|
22
|
+
MOONPAY: ['WIDGET', 'CARD'],
|
|
23
|
+
CDP: ['WIDGET', 'APPLE_PAY'],
|
|
24
|
+
MERCURYO: ['WIDGET', 'APPLE_PAY'],
|
|
25
|
+
BRALE: ['BANK'],
|
|
26
|
+
};
|
|
11
27
|
/** @deprecated use `TOnRampAsset` string union instead */
|
|
12
28
|
export var OnRampAsset;
|
|
13
29
|
(function (OnRampAsset) {
|
package/dist/esm/types/auth.js
CHANGED
|
@@ -54,6 +54,10 @@ export const OAUTH_METHODS = [
|
|
|
54
54
|
'FARCASTER',
|
|
55
55
|
'TELEGRAM',
|
|
56
56
|
'CUSTOM_OIDC',
|
|
57
|
+
// A partner-configured OAuth2 provider Para ships no first-party adapter for (e.g. Spotify). The specific
|
|
58
|
+
// connection rides on the flow's providerConfigHandle; the generic OAuth2 client uses the connection's
|
|
59
|
+
// stored endpoints. (ENG-7008)
|
|
60
|
+
'CUSTOM_OAUTH',
|
|
57
61
|
];
|
|
58
62
|
export const LINKED_ACCOUNT_TYPES = [
|
|
59
63
|
'EMAIL',
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Headless on-ramp types, shared between the server and the web-sdk client so request/response shapes
|
|
2
|
+
// aren't duplicated across the server and the user-management-client.
|
|
3
|
+
//
|
|
4
|
+
// Each headless (native Apple Pay / Platform SDK) provider has its own router and route per action —
|
|
5
|
+
// POST /users/:userId/onramp/<provider>/<action> — with its param/result types defined below. CDP
|
|
6
|
+
// (Coinbase) is the only provider defined + wired today; Mercuryo and MoonPay add their types here when
|
|
7
|
+
// they land on their own branches.
|
|
8
|
+
export {};
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export * from './assets.js';
|
|
2
2
|
export * from './auth.js';
|
|
3
|
+
export * from './headlessOnRamp.js';
|
|
3
4
|
export * from './authFactor.js';
|
|
4
5
|
export * from './authState.js';
|
|
5
6
|
export * from './modal.js';
|
|
6
7
|
export * from './otp.js';
|
|
7
8
|
export * from './params.js';
|
|
8
9
|
export * from './partner.js';
|
|
10
|
+
export * from './sdkCapabilities.js';
|
|
9
11
|
export * from './partnerAppConfig.js';
|
|
10
12
|
export * from './pending-transaction.js';
|
|
13
|
+
export * from './permissions.js';
|
|
11
14
|
export * from './signing.js';
|
|
12
15
|
export * from './theme.js';
|
|
13
16
|
export * from './transaction.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Client → server capability negotiation.
|
|
2
|
+
//
|
|
3
|
+
// The SDK advertises which features THIS build supports via a single request header, and the server gates
|
|
4
|
+
// behavior on the presence of a token rather than on an SDK version number. This keeps a capability coupled
|
|
5
|
+
// to the build that implements it (no cross-repo version guessing) and, unlike a header-per-feature, needs
|
|
6
|
+
// only ONE CORS `allowedHeaders` + `Vary` entry no matter how many capabilities are added.
|
|
7
|
+
//
|
|
8
|
+
// To add a capability: add a token below, send it from the SDK build that implements it
|
|
9
|
+
// (`serializeCapabilities`), and check for it on the server (`parseCapabilities(...).has(...)`).
|
|
10
|
+
export const SDK_CAPABILITIES_HEADER = 'x-para-capabilities';
|
|
11
|
+
export var SdkCapability;
|
|
12
|
+
(function (SdkCapability) {
|
|
13
|
+
// The build ships the on-ramp catalog picker, so it wants the OnRampConfigV2 (DB-reference) config shape
|
|
14
|
+
// from GET /on-ramp-config instead of the legacy assetInfo config. Checked server-side in onRampConfig.ts.
|
|
15
|
+
SdkCapability["OnRampCatalog"] = "onramp-catalog";
|
|
16
|
+
// The build can drive the Coinbase (CDP) headless on-ramp order flow. Advertised by the SDK now, but NOT
|
|
17
|
+
// yet gated server-side — the CDP order route serves everyone; wire a parseCapabilities(...).has(...) check
|
|
18
|
+
// here when the flow needs to condition on client support.
|
|
19
|
+
SdkCapability["CdpHeadless"] = "cdp-headless";
|
|
20
|
+
})(SdkCapability || (SdkCapability = {}));
|
|
21
|
+
const KNOWN_CAPABILITIES = new Set(Object.values(SdkCapability));
|
|
22
|
+
/** Serialize a build's supported capabilities into the header value (comma-separated tokens). */
|
|
23
|
+
export function serializeCapabilities(capabilities) {
|
|
24
|
+
return [...new Set(capabilities)].join(',');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse the capabilities header into the set of KNOWN capabilities the client advertised. Unknown tokens
|
|
28
|
+
* (e.g. a newer SDK advertising a capability this server doesn't understand yet) are ignored.
|
|
29
|
+
*/
|
|
30
|
+
export function parseCapabilities(header) {
|
|
31
|
+
const result = new Set();
|
|
32
|
+
if (!header)
|
|
33
|
+
return result;
|
|
34
|
+
for (const raw of header.split(',')) {
|
|
35
|
+
const token = raw.trim();
|
|
36
|
+
if (KNOWN_CAPABILITIES.has(token))
|
|
37
|
+
result.add(token);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|