@drawbridge/drawbridge-utils 0.0.174 → 0.0.176
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/connections/index.cjs +3202 -1831
- package/dist/connections/index.d.cts +11 -8866
- package/dist/connections/index.d.ts +11 -8866
- package/dist/connections/index.js +3183 -1827
- package/dist/connections/oauth.cjs +4 -4
- package/dist/connections/oauth.d.cts +10 -8
- package/dist/connections/oauth.d.ts +10 -8
- package/dist/connections/oauth.js +4 -4
- package/dist/features.cjs +7546 -42
- package/dist/features.d.cts +46 -42
- package/dist/features.d.ts +46 -42
- package/dist/features.js +7534 -42
- package/dist/index-B8JhYfvU.d.ts +11928 -0
- package/dist/index-qY18QITf.d.cts +11928 -0
- package/dist/plans.cjs +7542 -51
- package/dist/plans.d.cts +28 -10
- package/dist/plans.d.ts +28 -10
- package/dist/plans.js +7542 -51
- package/dist/pricing.cjs +7687 -209
- package/dist/pricing.d.cts +25 -17
- package/dist/pricing.d.ts +25 -17
- package/dist/pricing.js +7687 -209
- package/dist/providers.cjs +3084 -1891
- package/dist/providers.d.cts +8 -19
- package/dist/providers.d.ts +8 -19
- package/dist/providers.js +3081 -1888
- package/package.json +1 -1
|
@@ -43,9 +43,9 @@ var pkcePair = () => {
|
|
|
43
43
|
var consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) => {
|
|
44
44
|
var _a;
|
|
45
45
|
if (!clientId) throw new Error("This deployment has no OAuth client configured, so there is nothing to consent through");
|
|
46
|
-
if (!((_a = descriptor == null ? void 0 : descriptor.
|
|
46
|
+
if (!((_a = descriptor == null ? void 0 : descriptor.endpoints) == null ? void 0 : _a.authorize)) throw new Error("This connection declares no authorize endpoint");
|
|
47
47
|
if (descriptor.pkce && !challenge) throw new Error("This connection requires PKCE, so a code challenge is not optional");
|
|
48
|
-
return descriptor.
|
|
48
|
+
return descriptor.endpoints.authorize + "?" + new URLSearchParams({
|
|
49
49
|
// The descriptor's own params go FIRST, so a vendor quirk cannot quietly
|
|
50
50
|
// overwrite one of the fields below that every consent carries.
|
|
51
51
|
...descriptor.params || {},
|
|
@@ -73,12 +73,12 @@ var authToken = async ({
|
|
|
73
73
|
} = {}) => {
|
|
74
74
|
var _a;
|
|
75
75
|
if (!clientId || !clientSecret) throw new Error("This deployment has no OAuth client configured, so no token can be minted");
|
|
76
|
-
if (!((_a = descriptor == null ? void 0 : descriptor.
|
|
76
|
+
if (!((_a = descriptor == null ? void 0 : descriptor.endpoints) == null ? void 0 : _a.token)) throw new Error("This connection declares no token endpoint");
|
|
77
77
|
const renewing = !code;
|
|
78
78
|
if (renewing && !refreshToken) throw new Error("Nothing has been consented to yet, so there is no refresh token to spend");
|
|
79
79
|
if (!renewing && descriptor.pkce && !verifier) throw new Error("This connection requires PKCE, so the code verifier is not optional");
|
|
80
80
|
const client = credentials({ basic, clientId, clientSecret });
|
|
81
|
-
const response = await fetcher(descriptor.
|
|
81
|
+
const response = await fetcher(descriptor.endpoints.token, {
|
|
82
82
|
body: new URLSearchParams({
|
|
83
83
|
...client.body,
|
|
84
84
|
...renewing ? { grant_type: "refresh_token", refresh_token: refreshToken } : {
|
|
@@ -34,18 +34,20 @@ const credentials = ({ basic, clientId, clientSecret }) => (
|
|
|
34
34
|
// hand-written, so a second one copies every line.
|
|
35
35
|
//
|
|
36
36
|
// auth : {
|
|
37
|
-
//
|
|
37
|
+
// generated : false, install : false, keys : false, none : false,
|
|
38
38
|
// oauth : {
|
|
39
|
-
// urls : { authorize : 'https://login.mailchimp.com/oauth2/authorize',
|
|
40
39
|
// client : { id : 'MAILCHIMP_OAUTH_CLIENT_ID', secret : 'MAILCHIMP_OAUTH_CLIENT_SECRET' },
|
|
41
|
-
//
|
|
42
|
-
//
|
|
40
|
+
// endpoints : { authorize : 'https://login.mailchimp.com/oauth2/authorize',
|
|
41
|
+
// token : 'https://login.mailchimp.com/oauth2/token' },
|
|
43
42
|
// params : { ... }, optional vendor quirks
|
|
44
43
|
// pkce : true, Klaviyo's OAuth 2.1 requires it
|
|
45
44
|
// scopes : '...' optional; Mailchimp has none
|
|
46
45
|
// }
|
|
47
46
|
// }
|
|
48
47
|
//
|
|
48
|
+
// The SHAPE says which kind it is — exactly one of the five non-false — and
|
|
49
|
+
// build() injects auth.type and auth.oauth.callback from it.
|
|
50
|
+
//
|
|
49
51
|
// NO CREDENTIAL LIVES HERE OR IN A MANIFEST. `client` NAMES the environment
|
|
50
52
|
// variables holding OUR application's client — one identity, every merchant,
|
|
51
53
|
// which is what an OAuth client is. The token belongs to the merchant and
|
|
@@ -83,11 +85,11 @@ const consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) =
|
|
|
83
85
|
// fault nobody can fix from a connection page.
|
|
84
86
|
if( ! clientId ) throw new Error( 'This deployment has no OAuth client configured, so there is nothing to consent through' );
|
|
85
87
|
|
|
86
|
-
if( ! descriptor?.
|
|
88
|
+
if( ! descriptor?.endpoints?.authorize ) throw new Error( 'This connection declares no authorize endpoint' );
|
|
87
89
|
|
|
88
90
|
if( descriptor.pkce && ! challenge ) throw new Error( 'This connection requires PKCE, so a code challenge is not optional' );
|
|
89
91
|
|
|
90
|
-
return descriptor.
|
|
92
|
+
return descriptor.endpoints.authorize + '?' + new URLSearchParams({
|
|
91
93
|
// The descriptor's own params go FIRST, so a vendor quirk cannot quietly
|
|
92
94
|
// overwrite one of the fields below that every consent carries.
|
|
93
95
|
...( descriptor.params || {} ),
|
|
@@ -139,7 +141,7 @@ const authToken = async ({
|
|
|
139
141
|
} = {}) => {
|
|
140
142
|
|
|
141
143
|
if( ! clientId || ! clientSecret ) throw new Error( 'This deployment has no OAuth client configured, so no token can be minted' );
|
|
142
|
-
if( ! descriptor?.
|
|
144
|
+
if( ! descriptor?.endpoints?.token ) throw new Error( 'This connection declares no token endpoint' );
|
|
143
145
|
|
|
144
146
|
const renewing = ! code;
|
|
145
147
|
|
|
@@ -148,7 +150,7 @@ const authToken = async ({
|
|
|
148
150
|
|
|
149
151
|
const client = credentials({ basic, clientId, clientSecret });
|
|
150
152
|
|
|
151
|
-
const response = await fetcher( descriptor.
|
|
153
|
+
const response = await fetcher( descriptor.endpoints.token, {
|
|
152
154
|
body : new URLSearchParams({
|
|
153
155
|
...client.body,
|
|
154
156
|
...( renewing
|
|
@@ -34,18 +34,20 @@ const credentials = ({ basic, clientId, clientSecret }) => (
|
|
|
34
34
|
// hand-written, so a second one copies every line.
|
|
35
35
|
//
|
|
36
36
|
// auth : {
|
|
37
|
-
//
|
|
37
|
+
// generated : false, install : false, keys : false, none : false,
|
|
38
38
|
// oauth : {
|
|
39
|
-
// urls : { authorize : 'https://login.mailchimp.com/oauth2/authorize',
|
|
40
39
|
// client : { id : 'MAILCHIMP_OAUTH_CLIENT_ID', secret : 'MAILCHIMP_OAUTH_CLIENT_SECRET' },
|
|
41
|
-
//
|
|
42
|
-
//
|
|
40
|
+
// endpoints : { authorize : 'https://login.mailchimp.com/oauth2/authorize',
|
|
41
|
+
// token : 'https://login.mailchimp.com/oauth2/token' },
|
|
43
42
|
// params : { ... }, optional vendor quirks
|
|
44
43
|
// pkce : true, Klaviyo's OAuth 2.1 requires it
|
|
45
44
|
// scopes : '...' optional; Mailchimp has none
|
|
46
45
|
// }
|
|
47
46
|
// }
|
|
48
47
|
//
|
|
48
|
+
// The SHAPE says which kind it is — exactly one of the five non-false — and
|
|
49
|
+
// build() injects auth.type and auth.oauth.callback from it.
|
|
50
|
+
//
|
|
49
51
|
// NO CREDENTIAL LIVES HERE OR IN A MANIFEST. `client` NAMES the environment
|
|
50
52
|
// variables holding OUR application's client — one identity, every merchant,
|
|
51
53
|
// which is what an OAuth client is. The token belongs to the merchant and
|
|
@@ -83,11 +85,11 @@ const consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) =
|
|
|
83
85
|
// fault nobody can fix from a connection page.
|
|
84
86
|
if( ! clientId ) throw new Error( 'This deployment has no OAuth client configured, so there is nothing to consent through' );
|
|
85
87
|
|
|
86
|
-
if( ! descriptor?.
|
|
88
|
+
if( ! descriptor?.endpoints?.authorize ) throw new Error( 'This connection declares no authorize endpoint' );
|
|
87
89
|
|
|
88
90
|
if( descriptor.pkce && ! challenge ) throw new Error( 'This connection requires PKCE, so a code challenge is not optional' );
|
|
89
91
|
|
|
90
|
-
return descriptor.
|
|
92
|
+
return descriptor.endpoints.authorize + '?' + new URLSearchParams({
|
|
91
93
|
// The descriptor's own params go FIRST, so a vendor quirk cannot quietly
|
|
92
94
|
// overwrite one of the fields below that every consent carries.
|
|
93
95
|
...( descriptor.params || {} ),
|
|
@@ -139,7 +141,7 @@ const authToken = async ({
|
|
|
139
141
|
} = {}) => {
|
|
140
142
|
|
|
141
143
|
if( ! clientId || ! clientSecret ) throw new Error( 'This deployment has no OAuth client configured, so no token can be minted' );
|
|
142
|
-
if( ! descriptor?.
|
|
144
|
+
if( ! descriptor?.endpoints?.token ) throw new Error( 'This connection declares no token endpoint' );
|
|
143
145
|
|
|
144
146
|
const renewing = ! code;
|
|
145
147
|
|
|
@@ -148,7 +150,7 @@ const authToken = async ({
|
|
|
148
150
|
|
|
149
151
|
const client = credentials({ basic, clientId, clientSecret });
|
|
150
152
|
|
|
151
|
-
const response = await fetcher( descriptor.
|
|
153
|
+
const response = await fetcher( descriptor.endpoints.token, {
|
|
152
154
|
body : new URLSearchParams({
|
|
153
155
|
...client.body,
|
|
154
156
|
...( renewing
|
|
@@ -18,9 +18,9 @@ var pkcePair = () => {
|
|
|
18
18
|
var consentUrl = ({ challenge, clientId, descriptor, redirect, state } = {}) => {
|
|
19
19
|
var _a;
|
|
20
20
|
if (!clientId) throw new Error("This deployment has no OAuth client configured, so there is nothing to consent through");
|
|
21
|
-
if (!((_a = descriptor == null ? void 0 : descriptor.
|
|
21
|
+
if (!((_a = descriptor == null ? void 0 : descriptor.endpoints) == null ? void 0 : _a.authorize)) throw new Error("This connection declares no authorize endpoint");
|
|
22
22
|
if (descriptor.pkce && !challenge) throw new Error("This connection requires PKCE, so a code challenge is not optional");
|
|
23
|
-
return descriptor.
|
|
23
|
+
return descriptor.endpoints.authorize + "?" + new URLSearchParams({
|
|
24
24
|
// The descriptor's own params go FIRST, so a vendor quirk cannot quietly
|
|
25
25
|
// overwrite one of the fields below that every consent carries.
|
|
26
26
|
...descriptor.params || {},
|
|
@@ -48,12 +48,12 @@ var authToken = async ({
|
|
|
48
48
|
} = {}) => {
|
|
49
49
|
var _a;
|
|
50
50
|
if (!clientId || !clientSecret) throw new Error("This deployment has no OAuth client configured, so no token can be minted");
|
|
51
|
-
if (!((_a = descriptor == null ? void 0 : descriptor.
|
|
51
|
+
if (!((_a = descriptor == null ? void 0 : descriptor.endpoints) == null ? void 0 : _a.token)) throw new Error("This connection declares no token endpoint");
|
|
52
52
|
const renewing = !code;
|
|
53
53
|
if (renewing && !refreshToken) throw new Error("Nothing has been consented to yet, so there is no refresh token to spend");
|
|
54
54
|
if (!renewing && descriptor.pkce && !verifier) throw new Error("This connection requires PKCE, so the code verifier is not optional");
|
|
55
55
|
const client = credentials({ basic, clientId, clientSecret });
|
|
56
|
-
const response = await fetcher(descriptor.
|
|
56
|
+
const response = await fetcher(descriptor.endpoints.token, {
|
|
57
57
|
body: new URLSearchParams({
|
|
58
58
|
...client.body,
|
|
59
59
|
...renewing ? { grant_type: "refresh_token", refresh_token: refreshToken } : {
|