@zapier/zapier-sdk 0.18.4 → 0.19.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/CHANGELOG.md +35 -0
- package/README.md +43 -31
- package/dist/index.cjs +365 -64
- package/dist/index.d.mts +220 -33
- package/dist/index.d.ts +2541 -40
- package/dist/index.mjs +345 -63
- package/package.json +14 -13
- package/dist/api/auth.d.ts +0 -19
- package/dist/api/auth.d.ts.map +0 -1
- package/dist/api/auth.js +0 -70
- package/dist/api/auth.test.d.ts +0 -2
- package/dist/api/auth.test.d.ts.map +0 -1
- package/dist/api/auth.test.js +0 -220
- package/dist/api/client.d.ts +0 -9
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -356
- package/dist/api/client.test.d.ts +0 -2
- package/dist/api/client.test.d.ts.map +0 -1
- package/dist/api/client.test.js +0 -96
- package/dist/api/debug.d.ts +0 -14
- package/dist/api/debug.d.ts.map +0 -1
- package/dist/api/debug.js +0 -131
- package/dist/api/debug.test.d.ts +0 -2
- package/dist/api/debug.test.d.ts.map +0 -1
- package/dist/api/debug.test.js +0 -59
- package/dist/api/index.d.ts +0 -30
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -43
- package/dist/api/polling.d.ts +0 -46
- package/dist/api/polling.d.ts.map +0 -1
- package/dist/api/polling.js +0 -139
- package/dist/api/polling.test.d.ts +0 -2
- package/dist/api/polling.test.d.ts.map +0 -1
- package/dist/api/polling.test.js +0 -318
- package/dist/api/schemas.d.ts +0 -422
- package/dist/api/schemas.d.ts.map +0 -1
- package/dist/api/schemas.js +0 -322
- package/dist/api/types.d.ts +0 -83
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -1
- package/dist/auth.d.ts +0 -52
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -72
- package/dist/auth.test.d.ts +0 -2
- package/dist/auth.test.d.ts.map +0 -1
- package/dist/auth.test.js +0 -102
- package/dist/constants.d.ts +0 -14
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -42
- package/dist/plugins/api/index.d.ts +0 -12
- package/dist/plugins/api/index.d.ts.map +0 -1
- package/dist/plugins/api/index.js +0 -24
- package/dist/plugins/apps/index.d.ts +0 -15
- package/dist/plugins/apps/index.d.ts.map +0 -1
- package/dist/plugins/apps/index.js +0 -112
- package/dist/plugins/apps/schemas.d.ts +0 -42
- package/dist/plugins/apps/schemas.d.ts.map +0 -1
- package/dist/plugins/apps/schemas.js +0 -14
- package/dist/plugins/eventEmission/builders.d.ts +0 -14
- package/dist/plugins/eventEmission/builders.d.ts.map +0 -1
- package/dist/plugins/eventEmission/builders.js +0 -109
- package/dist/plugins/eventEmission/index.d.ts +0 -38
- package/dist/plugins/eventEmission/index.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.js +0 -336
- package/dist/plugins/eventEmission/index.test.d.ts +0 -5
- package/dist/plugins/eventEmission/index.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/index.test.js +0 -581
- package/dist/plugins/eventEmission/transport.d.ts +0 -27
- package/dist/plugins/eventEmission/transport.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.js +0 -104
- package/dist/plugins/eventEmission/transport.test.d.ts +0 -5
- package/dist/plugins/eventEmission/transport.test.d.ts.map +0 -1
- package/dist/plugins/eventEmission/transport.test.js +0 -164
- package/dist/plugins/eventEmission/types.d.ts +0 -63
- package/dist/plugins/eventEmission/types.d.ts.map +0 -1
- package/dist/plugins/eventEmission/types.js +0 -1
- package/dist/plugins/eventEmission/utils.d.ts +0 -45
- package/dist/plugins/eventEmission/utils.d.ts.map +0 -1
- package/dist/plugins/eventEmission/utils.js +0 -114
- package/dist/plugins/fetch/index.d.ts +0 -36
- package/dist/plugins/fetch/index.d.ts.map +0 -1
- package/dist/plugins/fetch/index.js +0 -62
- package/dist/plugins/fetch/schemas.d.ts +0 -19
- package/dist/plugins/fetch/schemas.d.ts.map +0 -1
- package/dist/plugins/fetch/schemas.js +0 -31
- package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.js +0 -36
- package/dist/plugins/findFirstAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +0 -177
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/schemas.js +0 -18
- package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.js +0 -39
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.test.js +0 -159
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -20
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/schemas.js +0 -18
- package/dist/plugins/getAction/index.d.ts +0 -25
- package/dist/plugins/getAction/index.d.ts.map +0 -1
- package/dist/plugins/getAction/index.js +0 -42
- package/dist/plugins/getAction/index.test.d.ts +0 -2
- package/dist/plugins/getAction/index.test.d.ts.map +0 -1
- package/dist/plugins/getAction/index.test.js +0 -211
- package/dist/plugins/getAction/schemas.d.ts +0 -30
- package/dist/plugins/getAction/schemas.d.ts.map +0 -1
- package/dist/plugins/getAction/schemas.js +0 -12
- package/dist/plugins/getApp/index.d.ts +0 -21
- package/dist/plugins/getApp/index.d.ts.map +0 -1
- package/dist/plugins/getApp/index.js +0 -44
- package/dist/plugins/getApp/index.test.d.ts +0 -2
- package/dist/plugins/getApp/index.test.d.ts.map +0 -1
- package/dist/plugins/getApp/index.test.js +0 -157
- package/dist/plugins/getApp/schemas.d.ts +0 -16
- package/dist/plugins/getApp/schemas.d.ts.map +0 -1
- package/dist/plugins/getApp/schemas.js +0 -8
- package/dist/plugins/getAuthentication/index.d.ts +0 -21
- package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.js +0 -29
- package/dist/plugins/getAuthentication/index.test.d.ts +0 -2
- package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.test.js +0 -106
- package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
- package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/schemas.js +0 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +0 -23
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.js +0 -53
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +0 -2
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/index.test.js +0 -291
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -28
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +0 -1
- package/dist/plugins/getInputFieldsSchema/schemas.js +0 -13
- package/dist/plugins/getProfile/index.d.ts +0 -25
- package/dist/plugins/getProfile/index.d.ts.map +0 -1
- package/dist/plugins/getProfile/index.js +0 -39
- package/dist/plugins/getProfile/schemas.d.ts +0 -13
- package/dist/plugins/getProfile/schemas.d.ts.map +0 -1
- package/dist/plugins/getProfile/schemas.js +0 -6
- package/dist/plugins/listActions/index.d.ts +0 -30
- package/dist/plugins/listActions/index.d.ts.map +0 -1
- package/dist/plugins/listActions/index.js +0 -75
- package/dist/plugins/listActions/index.test.d.ts +0 -2
- package/dist/plugins/listActions/index.test.d.ts.map +0 -1
- package/dist/plugins/listActions/index.test.js +0 -453
- package/dist/plugins/listActions/schemas.d.ts +0 -35
- package/dist/plugins/listActions/schemas.d.ts.map +0 -1
- package/dist/plugins/listActions/schemas.js +0 -22
- package/dist/plugins/listApps/index.d.ts +0 -19
- package/dist/plugins/listApps/index.d.ts.map +0 -1
- package/dist/plugins/listApps/index.js +0 -67
- package/dist/plugins/listApps/index.test.d.ts +0 -2
- package/dist/plugins/listApps/index.test.d.ts.map +0 -1
- package/dist/plugins/listApps/index.test.js +0 -121
- package/dist/plugins/listApps/schemas.d.ts +0 -47
- package/dist/plugins/listApps/schemas.d.ts.map +0 -1
- package/dist/plugins/listApps/schemas.js +0 -49
- package/dist/plugins/listAuthentications/index.d.ts +0 -24
- package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.js +0 -77
- package/dist/plugins/listAuthentications/index.test.d.ts +0 -2
- package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.test.js +0 -848
- package/dist/plugins/listAuthentications/schemas.d.ts +0 -30
- package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/schemas.js +0 -32
- package/dist/plugins/listInputFieldChoices/index.d.ts +0 -33
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.js +0 -115
- package/dist/plugins/listInputFieldChoices/index.test.d.ts +0 -2
- package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/index.test.js +0 -717
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -43
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +0 -65
- package/dist/plugins/listInputFields/index.d.ts +0 -34
- package/dist/plugins/listInputFields/index.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.js +0 -204
- package/dist/plugins/listInputFields/index.test.d.ts +0 -2
- package/dist/plugins/listInputFields/index.test.d.ts.map +0 -1
- package/dist/plugins/listInputFields/index.test.js +0 -359
- package/dist/plugins/listInputFields/schemas.d.ts +0 -35
- package/dist/plugins/listInputFields/schemas.d.ts.map +0 -1
- package/dist/plugins/listInputFields/schemas.js +0 -23
- package/dist/plugins/manifest/index.d.ts +0 -85
- package/dist/plugins/manifest/index.d.ts.map +0 -1
- package/dist/plugins/manifest/index.js +0 -376
- package/dist/plugins/manifest/index.test.d.ts +0 -2
- package/dist/plugins/manifest/index.test.d.ts.map +0 -1
- package/dist/plugins/manifest/index.test.js +0 -1139
- package/dist/plugins/manifest/schemas.d.ts +0 -57
- package/dist/plugins/manifest/schemas.d.ts.map +0 -1
- package/dist/plugins/manifest/schemas.js +0 -50
- package/dist/plugins/registry/index.d.ts +0 -21
- package/dist/plugins/registry/index.d.ts.map +0 -1
- package/dist/plugins/registry/index.js +0 -117
- package/dist/plugins/request/index.d.ts +0 -21
- package/dist/plugins/request/index.d.ts.map +0 -1
- package/dist/plugins/request/index.js +0 -76
- package/dist/plugins/request/index.test.d.ts +0 -2
- package/dist/plugins/request/index.test.d.ts.map +0 -1
- package/dist/plugins/request/index.test.js +0 -337
- package/dist/plugins/request/schemas.d.ts +0 -54
- package/dist/plugins/request/schemas.d.ts.map +0 -1
- package/dist/plugins/request/schemas.js +0 -41
- package/dist/plugins/runAction/index.d.ts +0 -33
- package/dist/plugins/runAction/index.d.ts.map +0 -1
- package/dist/plugins/runAction/index.js +0 -108
- package/dist/plugins/runAction/index.test.d.ts +0 -2
- package/dist/plugins/runAction/index.test.d.ts.map +0 -1
- package/dist/plugins/runAction/index.test.js +0 -333
- package/dist/plugins/runAction/schemas.d.ts +0 -34
- package/dist/plugins/runAction/schemas.d.ts.map +0 -1
- package/dist/plugins/runAction/schemas.js +0 -23
- package/dist/resolvers/actionKey.d.ts +0 -15
- package/dist/resolvers/actionKey.d.ts.map +0 -1
- package/dist/resolvers/actionKey.js +0 -19
- package/dist/resolvers/actionType.d.ts +0 -10
- package/dist/resolvers/actionType.d.ts.map +0 -1
- package/dist/resolvers/actionType.js +0 -21
- package/dist/resolvers/appKey.d.ts +0 -3
- package/dist/resolvers/appKey.d.ts.map +0 -1
- package/dist/resolvers/appKey.js +0 -5
- package/dist/resolvers/authenticationId.d.ts +0 -9
- package/dist/resolvers/authenticationId.d.ts.map +0 -1
- package/dist/resolvers/authenticationId.js +0 -42
- package/dist/resolvers/index.d.ts +0 -8
- package/dist/resolvers/index.d.ts.map +0 -1
- package/dist/resolvers/index.js +0 -8
- package/dist/resolvers/inputFieldKey.d.ts +0 -11
- package/dist/resolvers/inputFieldKey.d.ts.map +0 -1
- package/dist/resolvers/inputFieldKey.js +0 -47
- package/dist/resolvers/inputs.d.ts +0 -17
- package/dist/resolvers/inputs.d.ts.map +0 -1
- package/dist/resolvers/inputs.js +0 -50
- package/dist/schemas/Action.d.ts +0 -24
- package/dist/schemas/Action.d.ts.map +0 -1
- package/dist/schemas/Action.js +0 -40
- package/dist/schemas/App.d.ts +0 -57
- package/dist/schemas/App.d.ts.map +0 -1
- package/dist/schemas/App.js +0 -26
- package/dist/schemas/Auth.d.ts +0 -55
- package/dist/schemas/Auth.d.ts.map +0 -1
- package/dist/schemas/Auth.js +0 -33
- package/dist/schemas/Field.d.ts +0 -61
- package/dist/schemas/Field.d.ts.map +0 -1
- package/dist/schemas/Field.js +0 -116
- package/dist/schemas/Run.d.ts +0 -3
- package/dist/schemas/Run.d.ts.map +0 -1
- package/dist/schemas/Run.js +0 -31
- package/dist/schemas/UserProfile.d.ts +0 -13
- package/dist/schemas/UserProfile.d.ts.map +0 -1
- package/dist/schemas/UserProfile.js +0 -32
- package/dist/sdk.d.ts +0 -146
- package/dist/sdk.d.ts.map +0 -1
- package/dist/sdk.js +0 -112
- package/dist/sdk.test.d.ts +0 -2
- package/dist/sdk.test.d.ts.map +0 -1
- package/dist/sdk.test.js +0 -258
- package/dist/services/implementations.d.ts +0 -63
- package/dist/services/implementations.d.ts.map +0 -1
- package/dist/services/implementations.js +0 -80
- package/dist/types/domain.d.ts +0 -52
- package/dist/types/domain.d.ts.map +0 -1
- package/dist/types/domain.js +0 -1
- package/dist/types/domain.test.d.ts +0 -2
- package/dist/types/domain.test.d.ts.map +0 -1
- package/dist/types/domain.test.js +0 -39
- package/dist/types/errors.d.ts +0 -143
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/errors.js +0 -187
- package/dist/types/events.d.ts +0 -38
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -7
- package/dist/types/functions.d.ts +0 -27
- package/dist/types/functions.d.ts.map +0 -1
- package/dist/types/functions.js +0 -1
- package/dist/types/plugin.d.ts +0 -75
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/plugin.js +0 -9
- package/dist/types/properties.d.ts +0 -33
- package/dist/types/properties.d.ts.map +0 -1
- package/dist/types/properties.js +0 -52
- package/dist/types/sdk.d.ts +0 -69
- package/dist/types/sdk.d.ts.map +0 -1
- package/dist/types/sdk.js +0 -4
- package/dist/types/telemetry-events.d.ts +0 -105
- package/dist/types/telemetry-events.d.ts.map +0 -1
- package/dist/types/telemetry-events.js +0 -8
- package/dist/utils/array-utils.d.ts +0 -31
- package/dist/utils/array-utils.d.ts.map +0 -1
- package/dist/utils/array-utils.js +0 -36
- package/dist/utils/array-utils.test.d.ts +0 -2
- package/dist/utils/array-utils.test.d.ts.map +0 -1
- package/dist/utils/array-utils.test.js +0 -107
- package/dist/utils/batch-utils.d.ts +0 -72
- package/dist/utils/batch-utils.d.ts.map +0 -1
- package/dist/utils/batch-utils.js +0 -162
- package/dist/utils/batch-utils.test.d.ts +0 -2
- package/dist/utils/batch-utils.test.d.ts.map +0 -1
- package/dist/utils/batch-utils.test.js +0 -476
- package/dist/utils/domain-utils.d.ts +0 -66
- package/dist/utils/domain-utils.d.ts.map +0 -1
- package/dist/utils/domain-utils.js +0 -164
- package/dist/utils/domain-utils.test.d.ts +0 -2
- package/dist/utils/domain-utils.test.d.ts.map +0 -1
- package/dist/utils/domain-utils.test.js +0 -346
- package/dist/utils/file-utils.d.ts +0 -4
- package/dist/utils/file-utils.d.ts.map +0 -1
- package/dist/utils/file-utils.js +0 -74
- package/dist/utils/file-utils.test.d.ts +0 -2
- package/dist/utils/file-utils.test.d.ts.map +0 -1
- package/dist/utils/file-utils.test.js +0 -51
- package/dist/utils/function-utils.d.ts +0 -73
- package/dist/utils/function-utils.d.ts.map +0 -1
- package/dist/utils/function-utils.js +0 -245
- package/dist/utils/function-utils.test.d.ts +0 -2
- package/dist/utils/function-utils.test.d.ts.map +0 -1
- package/dist/utils/function-utils.test.js +0 -110
- package/dist/utils/id-utils.d.ts +0 -13
- package/dist/utils/id-utils.d.ts.map +0 -1
- package/dist/utils/id-utils.js +0 -22
- package/dist/utils/id-utils.test.d.ts +0 -2
- package/dist/utils/id-utils.test.d.ts.map +0 -1
- package/dist/utils/id-utils.test.js +0 -22
- package/dist/utils/pagination-utils.d.ts +0 -37
- package/dist/utils/pagination-utils.d.ts.map +0 -1
- package/dist/utils/pagination-utils.js +0 -165
- package/dist/utils/pagination-utils.test.d.ts +0 -17
- package/dist/utils/pagination-utils.test.d.ts.map +0 -1
- package/dist/utils/pagination-utils.test.js +0 -461
- package/dist/utils/retry-utils.d.ts +0 -45
- package/dist/utils/retry-utils.d.ts.map +0 -1
- package/dist/utils/retry-utils.js +0 -51
- package/dist/utils/retry-utils.test.d.ts +0 -2
- package/dist/utils/retry-utils.test.d.ts.map +0 -1
- package/dist/utils/retry-utils.test.js +0 -90
- package/dist/utils/schema-utils.d.ts +0 -69
- package/dist/utils/schema-utils.d.ts.map +0 -1
- package/dist/utils/schema-utils.js +0 -72
- package/dist/utils/string-utils.d.ts +0 -40
- package/dist/utils/string-utils.d.ts.map +0 -1
- package/dist/utils/string-utils.js +0 -69
- package/dist/utils/string-utils.test.d.ts +0 -2
- package/dist/utils/string-utils.test.d.ts.map +0 -1
- package/dist/utils/string-utils.test.js +0 -59
- package/dist/utils/telemetry-utils.d.ts +0 -44
- package/dist/utils/telemetry-utils.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.js +0 -55
- package/dist/utils/telemetry-utils.test.d.ts +0 -2
- package/dist/utils/telemetry-utils.test.d.ts.map +0 -1
- package/dist/utils/telemetry-utils.test.js +0 -94
- package/dist/utils/url-utils.d.ts +0 -19
- package/dist/utils/url-utils.d.ts.map +0 -1
- package/dist/utils/url-utils.js +0 -62
- package/dist/utils/url-utils.test.d.ts +0 -2
- package/dist/utils/url-utils.test.d.ts.map +0 -1
- package/dist/utils/url-utils.test.js +0 -103
- package/dist/utils/validation.d.ts +0 -4
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -30
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/dist/utils/validation.test.js +0 -44
package/dist/index.mjs
CHANGED
|
@@ -36,6 +36,14 @@ function isPositional(schema) {
|
|
|
36
36
|
// src/constants.ts
|
|
37
37
|
var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
|
|
38
38
|
var MAX_PAGE_LIMIT = 1e4;
|
|
39
|
+
var ZAPIER_CREDENTIALS = process.env.ZAPIER_CREDENTIALS;
|
|
40
|
+
var ZAPIER_CREDENTIALS_CLIENT_ID = process.env.ZAPIER_CREDENTIALS_CLIENT_ID;
|
|
41
|
+
var ZAPIER_CREDENTIALS_CLIENT_SECRET = process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET;
|
|
42
|
+
var ZAPIER_CREDENTIALS_BASE_URL = process.env.ZAPIER_CREDENTIALS_BASE_URL;
|
|
43
|
+
var ZAPIER_CREDENTIALS_SCOPE = process.env.ZAPIER_CREDENTIALS_SCOPE;
|
|
44
|
+
var ZAPIER_TOKEN = process.env.ZAPIER_TOKEN;
|
|
45
|
+
var ZAPIER_AUTH_BASE_URL = process.env.ZAPIER_AUTH_BASE_URL;
|
|
46
|
+
var ZAPIER_AUTH_CLIENT_ID = process.env.ZAPIER_AUTH_CLIENT_ID;
|
|
39
47
|
|
|
40
48
|
// src/types/properties.ts
|
|
41
49
|
var AppKeyPropertySchema = withPositional(
|
|
@@ -2087,6 +2095,9 @@ var listAuthenticationsPlugin = ({ context }) => {
|
|
|
2087
2095
|
if (options.owner) {
|
|
2088
2096
|
searchParams.owner = options.owner;
|
|
2089
2097
|
}
|
|
2098
|
+
if (options.isExpired !== void 0) {
|
|
2099
|
+
searchParams.isExpired = options.isExpired.toString();
|
|
2100
|
+
}
|
|
2090
2101
|
if (options.cursor) {
|
|
2091
2102
|
searchParams.offset = options.cursor;
|
|
2092
2103
|
}
|
|
@@ -2268,14 +2279,14 @@ var getAuthenticationPlugin = ({ context }) => {
|
|
|
2268
2279
|
}
|
|
2269
2280
|
};
|
|
2270
2281
|
};
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2282
|
+
|
|
2283
|
+
// src/plugins/findFirstAuthentication/schemas.ts
|
|
2284
|
+
var FindFirstAuthenticationSchema = ListAuthenticationsQuerySchema.omit({
|
|
2285
|
+
authenticationIds: true,
|
|
2286
|
+
pageSize: true,
|
|
2287
|
+
maxItems: true,
|
|
2288
|
+
cursor: true,
|
|
2289
|
+
_telemetry: true
|
|
2279
2290
|
}).describe("Find the first authentication matching the criteria");
|
|
2280
2291
|
|
|
2281
2292
|
// src/plugins/findFirstAuthentication/index.ts
|
|
@@ -2319,14 +2330,14 @@ var findFirstAuthenticationPlugin = ({ sdk, context }) => {
|
|
|
2319
2330
|
}
|
|
2320
2331
|
};
|
|
2321
2332
|
};
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2333
|
+
|
|
2334
|
+
// src/plugins/findUniqueAuthentication/schemas.ts
|
|
2335
|
+
var FindUniqueAuthenticationSchema = ListAuthenticationsQuerySchema.omit({
|
|
2336
|
+
authenticationIds: true,
|
|
2337
|
+
pageSize: true,
|
|
2338
|
+
maxItems: true,
|
|
2339
|
+
cursor: true,
|
|
2340
|
+
_telemetry: true
|
|
2330
2341
|
}).describe("Find a unique authentication matching the criteria");
|
|
2331
2342
|
|
|
2332
2343
|
// src/plugins/findUniqueAuthentication/index.ts
|
|
@@ -2729,8 +2740,11 @@ async function readManifestFromFile(filePath) {
|
|
|
2729
2740
|
const resolvedPath = await resolve(filePath);
|
|
2730
2741
|
const content = await readFile(resolvedPath);
|
|
2731
2742
|
return parseManifestContent(content, resolvedPath);
|
|
2732
|
-
} catch {
|
|
2733
|
-
|
|
2743
|
+
} catch (error) {
|
|
2744
|
+
const isFileNotFound = error && typeof error === "object" && "code" in error && error.code === "ENOENT" || error instanceof Error && error.message.includes("File not found");
|
|
2745
|
+
if (!isFileNotFound) {
|
|
2746
|
+
console.warn(`\u26A0\uFE0F Failed to read manifest from ${filePath}`);
|
|
2747
|
+
}
|
|
2734
2748
|
return null;
|
|
2735
2749
|
}
|
|
2736
2750
|
}
|
|
@@ -3443,36 +3457,29 @@ async function pollUntilComplete(options) {
|
|
|
3443
3457
|
}
|
|
3444
3458
|
}
|
|
3445
3459
|
|
|
3446
|
-
// src/
|
|
3447
|
-
function
|
|
3448
|
-
return
|
|
3460
|
+
// src/types/credentials.ts
|
|
3461
|
+
function isClientCredentials(credentials) {
|
|
3462
|
+
return typeof credentials === "object" && credentials !== null && "clientId" in credentials && "clientSecret" in credentials;
|
|
3449
3463
|
}
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
const { getToken } = await import('@zapier/zapier-sdk-cli-login');
|
|
3453
|
-
return await getToken(options);
|
|
3454
|
-
} catch {
|
|
3455
|
-
return void 0;
|
|
3456
|
-
}
|
|
3464
|
+
function isPkceCredentials(credentials) {
|
|
3465
|
+
return typeof credentials === "object" && credentials !== null && "clientId" in credentials && !("clientSecret" in credentials);
|
|
3457
3466
|
}
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
if (envToken) {
|
|
3461
|
-
return envToken;
|
|
3462
|
-
}
|
|
3463
|
-
return getTokenFromCliLogin(options);
|
|
3467
|
+
function isCredentialsObject(credentials) {
|
|
3468
|
+
return typeof credentials === "object" && credentials !== null && "clientId" in credentials;
|
|
3464
3469
|
}
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
}
|
|
3475
|
-
|
|
3470
|
+
function isCredentialsFunction(credentials) {
|
|
3471
|
+
return typeof credentials === "function";
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
// src/utils/logging.ts
|
|
3475
|
+
var loggedDeprecations = /* @__PURE__ */ new Set();
|
|
3476
|
+
function logDeprecation(message) {
|
|
3477
|
+
if (loggedDeprecations.has(message)) return;
|
|
3478
|
+
loggedDeprecations.add(message);
|
|
3479
|
+
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
3480
|
+
}
|
|
3481
|
+
function resetDeprecationWarnings() {
|
|
3482
|
+
loggedDeprecations.clear();
|
|
3476
3483
|
}
|
|
3477
3484
|
|
|
3478
3485
|
// src/utils/url-utils.ts
|
|
@@ -3521,6 +3528,278 @@ function getTrackingBaseUrl({
|
|
|
3521
3528
|
return ZAPIER_BASE_URL;
|
|
3522
3529
|
}
|
|
3523
3530
|
|
|
3531
|
+
// src/credentials.ts
|
|
3532
|
+
function deriveAuthBaseUrl(sdkBaseUrl) {
|
|
3533
|
+
if (!sdkBaseUrl) return void 0;
|
|
3534
|
+
return getZapierBaseUrl(sdkBaseUrl);
|
|
3535
|
+
}
|
|
3536
|
+
function normalizeCredentialsObject(obj, sdkBaseUrl) {
|
|
3537
|
+
const resolvedBaseUrl = obj.baseUrl || deriveAuthBaseUrl(sdkBaseUrl);
|
|
3538
|
+
if (obj.type === "client_credentials" || "clientSecret" in obj && obj.clientSecret) {
|
|
3539
|
+
return {
|
|
3540
|
+
type: "client_credentials",
|
|
3541
|
+
clientId: obj.clientId,
|
|
3542
|
+
clientSecret: obj.clientSecret,
|
|
3543
|
+
baseUrl: resolvedBaseUrl,
|
|
3544
|
+
scope: obj.scope
|
|
3545
|
+
};
|
|
3546
|
+
}
|
|
3547
|
+
return {
|
|
3548
|
+
type: "pkce",
|
|
3549
|
+
clientId: obj.clientId,
|
|
3550
|
+
baseUrl: resolvedBaseUrl,
|
|
3551
|
+
scope: obj.scope
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
function resolveCredentialsFromEnv(sdkBaseUrl) {
|
|
3555
|
+
if (ZAPIER_CREDENTIALS) {
|
|
3556
|
+
return ZAPIER_CREDENTIALS;
|
|
3557
|
+
}
|
|
3558
|
+
if (ZAPIER_CREDENTIALS_CLIENT_ID) {
|
|
3559
|
+
const resolvedBaseUrl = ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
3560
|
+
if (ZAPIER_CREDENTIALS_CLIENT_SECRET) {
|
|
3561
|
+
return {
|
|
3562
|
+
type: "client_credentials",
|
|
3563
|
+
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
3564
|
+
clientSecret: ZAPIER_CREDENTIALS_CLIENT_SECRET,
|
|
3565
|
+
baseUrl: resolvedBaseUrl,
|
|
3566
|
+
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
3567
|
+
};
|
|
3568
|
+
} else {
|
|
3569
|
+
return {
|
|
3570
|
+
type: "pkce",
|
|
3571
|
+
clientId: ZAPIER_CREDENTIALS_CLIENT_ID,
|
|
3572
|
+
baseUrl: resolvedBaseUrl,
|
|
3573
|
+
scope: ZAPIER_CREDENTIALS_SCOPE
|
|
3574
|
+
};
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
if (ZAPIER_TOKEN) {
|
|
3578
|
+
logDeprecation(
|
|
3579
|
+
"ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
|
|
3580
|
+
);
|
|
3581
|
+
return ZAPIER_TOKEN;
|
|
3582
|
+
}
|
|
3583
|
+
if (ZAPIER_AUTH_CLIENT_ID) {
|
|
3584
|
+
logDeprecation(
|
|
3585
|
+
"ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
|
|
3586
|
+
);
|
|
3587
|
+
if (ZAPIER_AUTH_BASE_URL) {
|
|
3588
|
+
logDeprecation(
|
|
3589
|
+
"ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
|
|
3590
|
+
);
|
|
3591
|
+
}
|
|
3592
|
+
const resolvedBaseUrl = ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
|
|
3593
|
+
return {
|
|
3594
|
+
type: "pkce",
|
|
3595
|
+
clientId: ZAPIER_AUTH_CLIENT_ID,
|
|
3596
|
+
baseUrl: resolvedBaseUrl
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
return void 0;
|
|
3600
|
+
}
|
|
3601
|
+
async function resolveCredentials(options = {}) {
|
|
3602
|
+
const { baseUrl } = options;
|
|
3603
|
+
if (options.credentials !== void 0) {
|
|
3604
|
+
if (isCredentialsFunction(options.credentials)) {
|
|
3605
|
+
const resolved = await options.credentials();
|
|
3606
|
+
if (typeof resolved === "function") {
|
|
3607
|
+
throw new Error(
|
|
3608
|
+
"Credentials function returned another function. Credentials functions must return a string or credentials object."
|
|
3609
|
+
);
|
|
3610
|
+
}
|
|
3611
|
+
if (isCredentialsObject(resolved)) {
|
|
3612
|
+
return normalizeCredentialsObject(resolved, baseUrl);
|
|
3613
|
+
}
|
|
3614
|
+
return resolved;
|
|
3615
|
+
}
|
|
3616
|
+
if (isCredentialsObject(options.credentials)) {
|
|
3617
|
+
return normalizeCredentialsObject(options.credentials, baseUrl);
|
|
3618
|
+
}
|
|
3619
|
+
return options.credentials;
|
|
3620
|
+
}
|
|
3621
|
+
if (options.token !== void 0) {
|
|
3622
|
+
logDeprecation(
|
|
3623
|
+
"The `token` option is deprecated. Use `credentials` instead."
|
|
3624
|
+
);
|
|
3625
|
+
return options.token;
|
|
3626
|
+
}
|
|
3627
|
+
const envCredentials = resolveCredentialsFromEnv(baseUrl);
|
|
3628
|
+
if (envCredentials !== void 0) {
|
|
3629
|
+
return envCredentials;
|
|
3630
|
+
}
|
|
3631
|
+
return void 0;
|
|
3632
|
+
}
|
|
3633
|
+
function getBaseUrlFromCredentials(credentials) {
|
|
3634
|
+
if (credentials && isCredentialsObject(credentials)) {
|
|
3635
|
+
return credentials.baseUrl;
|
|
3636
|
+
}
|
|
3637
|
+
return void 0;
|
|
3638
|
+
}
|
|
3639
|
+
function getClientIdFromCredentials(credentials) {
|
|
3640
|
+
if (credentials && isCredentialsObject(credentials)) {
|
|
3641
|
+
return credentials.clientId;
|
|
3642
|
+
}
|
|
3643
|
+
return void 0;
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
// src/auth.ts
|
|
3647
|
+
var tokenCache = /* @__PURE__ */ new Map();
|
|
3648
|
+
var pendingExchanges = /* @__PURE__ */ new Map();
|
|
3649
|
+
function clearTokenCache() {
|
|
3650
|
+
tokenCache.clear();
|
|
3651
|
+
pendingExchanges.clear();
|
|
3652
|
+
}
|
|
3653
|
+
var TOKEN_EXPIRATION_BUFFER = 5 * 60 * 1e3;
|
|
3654
|
+
function getCachedToken(clientId) {
|
|
3655
|
+
const cached = tokenCache.get(clientId);
|
|
3656
|
+
if (!cached) return void 0;
|
|
3657
|
+
if (cached.expiresAt > Date.now() + TOKEN_EXPIRATION_BUFFER) {
|
|
3658
|
+
return cached.accessToken;
|
|
3659
|
+
}
|
|
3660
|
+
tokenCache.delete(clientId);
|
|
3661
|
+
return void 0;
|
|
3662
|
+
}
|
|
3663
|
+
function cacheToken(clientId, accessToken, expiresIn) {
|
|
3664
|
+
tokenCache.set(clientId, {
|
|
3665
|
+
accessToken,
|
|
3666
|
+
expiresAt: Date.now() + expiresIn * 1e3
|
|
3667
|
+
});
|
|
3668
|
+
}
|
|
3669
|
+
function invalidateCachedToken(clientId) {
|
|
3670
|
+
tokenCache.delete(clientId);
|
|
3671
|
+
}
|
|
3672
|
+
function getTokenEndpointUrl(baseUrl) {
|
|
3673
|
+
const base = baseUrl || ZAPIER_BASE_URL;
|
|
3674
|
+
return `${base}/oauth/token/`;
|
|
3675
|
+
}
|
|
3676
|
+
async function exchangeClientCredentials(options) {
|
|
3677
|
+
const { clientId, clientSecret, baseUrl, scope, onEvent } = options;
|
|
3678
|
+
const fetchFn = options.fetch || globalThis.fetch;
|
|
3679
|
+
const tokenUrl = getTokenEndpointUrl(baseUrl);
|
|
3680
|
+
onEvent?.({
|
|
3681
|
+
type: "auth_exchanging",
|
|
3682
|
+
payload: {
|
|
3683
|
+
message: "Exchanging client credentials for token...",
|
|
3684
|
+
operation: "client_credentials"
|
|
3685
|
+
},
|
|
3686
|
+
timestamp: Date.now()
|
|
3687
|
+
});
|
|
3688
|
+
const response = await fetchFn(tokenUrl, {
|
|
3689
|
+
method: "POST",
|
|
3690
|
+
headers: {
|
|
3691
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
3692
|
+
},
|
|
3693
|
+
body: new URLSearchParams({
|
|
3694
|
+
grant_type: "client_credentials",
|
|
3695
|
+
client_id: clientId,
|
|
3696
|
+
client_secret: clientSecret,
|
|
3697
|
+
scope: scope || "external",
|
|
3698
|
+
audience: "zapier.com"
|
|
3699
|
+
})
|
|
3700
|
+
});
|
|
3701
|
+
if (!response.ok) {
|
|
3702
|
+
const errorText = await response.text();
|
|
3703
|
+
onEvent?.({
|
|
3704
|
+
type: "auth_error",
|
|
3705
|
+
payload: {
|
|
3706
|
+
message: `Client credentials exchange failed: ${response.status}`,
|
|
3707
|
+
error: errorText,
|
|
3708
|
+
operation: "client_credentials"
|
|
3709
|
+
},
|
|
3710
|
+
timestamp: Date.now()
|
|
3711
|
+
});
|
|
3712
|
+
throw new Error(
|
|
3713
|
+
`Client credentials exchange failed: ${response.status} ${response.statusText}`
|
|
3714
|
+
);
|
|
3715
|
+
}
|
|
3716
|
+
const data = await response.json();
|
|
3717
|
+
if (!data.access_token) {
|
|
3718
|
+
throw new Error("Client credentials response missing access_token");
|
|
3719
|
+
}
|
|
3720
|
+
const expiresIn = data.expires_in || 3600;
|
|
3721
|
+
cacheToken(clientId, data.access_token, expiresIn);
|
|
3722
|
+
onEvent?.({
|
|
3723
|
+
type: "auth_success",
|
|
3724
|
+
payload: {
|
|
3725
|
+
message: "Client credentials exchange successful",
|
|
3726
|
+
operation: "client_credentials"
|
|
3727
|
+
},
|
|
3728
|
+
timestamp: Date.now()
|
|
3729
|
+
});
|
|
3730
|
+
return data.access_token;
|
|
3731
|
+
}
|
|
3732
|
+
async function getTokenFromCliLogin(options) {
|
|
3733
|
+
try {
|
|
3734
|
+
const cliLogin = await import('@zapier/zapier-sdk-cli-login');
|
|
3735
|
+
return await cliLogin.getToken(options);
|
|
3736
|
+
} catch {
|
|
3737
|
+
return void 0;
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
async function resolveAuthToken(options = {}) {
|
|
3741
|
+
const credentials = await resolveCredentials({
|
|
3742
|
+
credentials: options.credentials,
|
|
3743
|
+
token: options.token
|
|
3744
|
+
});
|
|
3745
|
+
if (credentials !== void 0) {
|
|
3746
|
+
return resolveAuthTokenFromCredentials(credentials, options);
|
|
3747
|
+
}
|
|
3748
|
+
return getTokenFromCliLogin({
|
|
3749
|
+
onEvent: options.onEvent,
|
|
3750
|
+
fetch: options.fetch
|
|
3751
|
+
});
|
|
3752
|
+
}
|
|
3753
|
+
async function resolveAuthTokenFromCredentials(credentials, options) {
|
|
3754
|
+
if (typeof credentials === "string") {
|
|
3755
|
+
return credentials;
|
|
3756
|
+
}
|
|
3757
|
+
if (isClientCredentials(credentials)) {
|
|
3758
|
+
const { clientId } = credentials;
|
|
3759
|
+
const cached = getCachedToken(clientId);
|
|
3760
|
+
if (cached) {
|
|
3761
|
+
return cached;
|
|
3762
|
+
}
|
|
3763
|
+
const pending = pendingExchanges.get(clientId);
|
|
3764
|
+
if (pending) {
|
|
3765
|
+
return pending;
|
|
3766
|
+
}
|
|
3767
|
+
const exchangePromise = exchangeClientCredentials({
|
|
3768
|
+
clientId: credentials.clientId,
|
|
3769
|
+
clientSecret: credentials.clientSecret,
|
|
3770
|
+
baseUrl: credentials.baseUrl || options.baseUrl,
|
|
3771
|
+
scope: credentials.scope,
|
|
3772
|
+
fetch: options.fetch,
|
|
3773
|
+
onEvent: options.onEvent
|
|
3774
|
+
}).finally(() => {
|
|
3775
|
+
pendingExchanges.delete(clientId);
|
|
3776
|
+
});
|
|
3777
|
+
pendingExchanges.set(clientId, exchangePromise);
|
|
3778
|
+
return exchangePromise;
|
|
3779
|
+
}
|
|
3780
|
+
if (isPkceCredentials(credentials)) {
|
|
3781
|
+
const storedToken = await getTokenFromCliLogin({
|
|
3782
|
+
onEvent: options.onEvent,
|
|
3783
|
+
fetch: options.fetch,
|
|
3784
|
+
credentials
|
|
3785
|
+
});
|
|
3786
|
+
if (storedToken) {
|
|
3787
|
+
return storedToken;
|
|
3788
|
+
}
|
|
3789
|
+
throw new Error(
|
|
3790
|
+
"PKCE credentials require interactive login. Please run the 'login' command with the CLI first, or use client_credentials flow."
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
throw new Error("Unknown credentials type");
|
|
3794
|
+
}
|
|
3795
|
+
async function invalidateCredentialsToken(options) {
|
|
3796
|
+
const resolved = await resolveCredentials(options);
|
|
3797
|
+
const clientId = getClientIdFromCredentials(resolved);
|
|
3798
|
+
if (clientId) {
|
|
3799
|
+
invalidateCachedToken(clientId);
|
|
3800
|
+
}
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3524
3803
|
// src/api/client.ts
|
|
3525
3804
|
var pathConfig = {
|
|
3526
3805
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3578,13 +3857,11 @@ var ZapierApiClient = class {
|
|
|
3578
3857
|
// Helper to get a token from the different places it could be gotten
|
|
3579
3858
|
async getAuthToken() {
|
|
3580
3859
|
return resolveAuthToken({
|
|
3860
|
+
credentials: this.options.credentials,
|
|
3581
3861
|
token: this.options.token,
|
|
3582
|
-
getToken: this.options.getToken,
|
|
3583
3862
|
onEvent: this.options.onEvent,
|
|
3584
3863
|
fetch: this.options.fetch,
|
|
3585
|
-
baseUrl: this.options.baseUrl
|
|
3586
|
-
authBaseUrl: this.options.authBaseUrl,
|
|
3587
|
-
authClientId: this.options.authClientId
|
|
3864
|
+
baseUrl: this.options.baseUrl
|
|
3588
3865
|
});
|
|
3589
3866
|
}
|
|
3590
3867
|
// Helper to handle responses
|
|
@@ -3622,10 +3899,16 @@ var ZapierApiClient = class {
|
|
|
3622
3899
|
if (response.status === 401 || response.status === 403) {
|
|
3623
3900
|
if (wasMissingAuthToken) {
|
|
3624
3901
|
throw new ZapierAuthenticationError(
|
|
3625
|
-
`Authentication required (HTTP ${response.status}). Please provide
|
|
3902
|
+
`Authentication required (HTTP ${response.status}). Please provide credentials in options or set ZAPIER_CREDENTIALS environment variable.`,
|
|
3626
3903
|
errorOptions
|
|
3627
3904
|
);
|
|
3628
3905
|
}
|
|
3906
|
+
if (response.status === 401) {
|
|
3907
|
+
await invalidateCredentialsToken({
|
|
3908
|
+
credentials: this.options.credentials,
|
|
3909
|
+
token: this.options.token
|
|
3910
|
+
});
|
|
3911
|
+
}
|
|
3629
3912
|
throw new ZapierAuthenticationError(message, errorOptions);
|
|
3630
3913
|
}
|
|
3631
3914
|
if (response.status === 400) {
|
|
@@ -3761,7 +4044,7 @@ var ZapierApiClient = class {
|
|
|
3761
4044
|
if (options.authRequired) {
|
|
3762
4045
|
if (headers.get("Authorization") == null && authToken == null) {
|
|
3763
4046
|
throw new ZapierAuthenticationError(
|
|
3764
|
-
`Authentication required but no
|
|
4047
|
+
`Authentication required but no credentials available. Please set ZAPIER_CREDENTIALS, or run the 'login' command with the CLI.`
|
|
3765
4048
|
);
|
|
3766
4049
|
}
|
|
3767
4050
|
}
|
|
@@ -3837,27 +4120,28 @@ var apiPlugin = (params) => {
|
|
|
3837
4120
|
const {
|
|
3838
4121
|
fetch: customFetch = globalThis.fetch,
|
|
3839
4122
|
baseUrl = ZAPIER_BASE_URL,
|
|
3840
|
-
|
|
3841
|
-
authClientId,
|
|
4123
|
+
credentials,
|
|
3842
4124
|
token,
|
|
3843
|
-
getToken,
|
|
3844
4125
|
onEvent,
|
|
3845
4126
|
debug = false
|
|
3846
4127
|
} = params.context.options;
|
|
3847
4128
|
const api = createZapierApi({
|
|
3848
4129
|
baseUrl,
|
|
3849
|
-
|
|
3850
|
-
authClientId,
|
|
4130
|
+
credentials,
|
|
3851
4131
|
token,
|
|
3852
|
-
getToken,
|
|
3853
4132
|
debug,
|
|
3854
4133
|
fetch: customFetch,
|
|
3855
4134
|
onEvent
|
|
3856
4135
|
});
|
|
3857
4136
|
return {
|
|
3858
4137
|
context: {
|
|
3859
|
-
api
|
|
4138
|
+
api,
|
|
3860
4139
|
// Provide API client in context for other plugins to use
|
|
4140
|
+
resolveCredentials: () => resolveCredentials({
|
|
4141
|
+
credentials,
|
|
4142
|
+
token,
|
|
4143
|
+
baseUrl
|
|
4144
|
+
})
|
|
3861
4145
|
}
|
|
3862
4146
|
};
|
|
3863
4147
|
};
|
|
@@ -4451,7 +4735,7 @@ function getCpuTime() {
|
|
|
4451
4735
|
|
|
4452
4736
|
// package.json
|
|
4453
4737
|
var package_default = {
|
|
4454
|
-
version: "0.
|
|
4738
|
+
version: "0.19.0"};
|
|
4455
4739
|
|
|
4456
4740
|
// src/plugins/eventEmission/builders.ts
|
|
4457
4741
|
function createBaseEvent(context = {}) {
|
|
@@ -4624,11 +4908,9 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
4624
4908
|
const getUserContext = (async () => {
|
|
4625
4909
|
try {
|
|
4626
4910
|
const token = await resolveAuthToken({
|
|
4911
|
+
credentials: context.options.credentials,
|
|
4627
4912
|
token: context.options.token,
|
|
4628
|
-
getToken: context.options.getToken,
|
|
4629
4913
|
baseUrl: context.options.baseUrl,
|
|
4630
|
-
authBaseUrl: context.options.authBaseUrl,
|
|
4631
|
-
authClientId: context.options.authClientId,
|
|
4632
4914
|
onEvent: context.options.onEvent,
|
|
4633
4915
|
fetch: context.options.fetch
|
|
4634
4916
|
});
|
|
@@ -4893,4 +5175,4 @@ function createZapierSdk(options = {}) {
|
|
|
4893
5175
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
4894
5176
|
}
|
|
4895
5177
|
|
|
4896
|
-
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_BASE_URL, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getCiPlatform, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin,
|
|
5178
|
+
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZAPIER_AUTH_BASE_URL, ZAPIER_AUTH_CLIENT_ID, ZAPIER_BASE_URL, ZAPIER_CREDENTIALS, ZAPIER_CREDENTIALS_BASE_URL, ZAPIER_CREDENTIALS_CLIENT_ID, ZAPIER_CREDENTIALS_CLIENT_SECRET, ZAPIER_CREDENTIALS_SCOPE, ZAPIER_TOKEN, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, createBaseEvent, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTokenFromCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, toSnakeCase, toTitleCase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,6 +22,15 @@
|
|
|
22
22
|
"README.md",
|
|
23
23
|
"CHANGELOG.md"
|
|
24
24
|
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"rebuild": "pnpm clean && pnpm build",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"typecheck": "tsc --project tsconfig.build.json --noEmit",
|
|
31
|
+
"test": "vitest",
|
|
32
|
+
"prepublishOnly": "node ../../scripts/check-version.js"
|
|
33
|
+
},
|
|
25
34
|
"keywords": [
|
|
26
35
|
"zapier",
|
|
27
36
|
"sdk",
|
|
@@ -36,7 +45,7 @@
|
|
|
36
45
|
"access": "public"
|
|
37
46
|
},
|
|
38
47
|
"dependencies": {
|
|
39
|
-
"@zapier/zapier-sdk-core": "^0.
|
|
48
|
+
"@zapier/zapier-sdk-core": "^0.6.0",
|
|
40
49
|
"zod": "4.2.1"
|
|
41
50
|
},
|
|
42
51
|
"peerDependencies": {
|
|
@@ -49,17 +58,9 @@
|
|
|
49
58
|
},
|
|
50
59
|
"devDependencies": {
|
|
51
60
|
"@types/node": "^24.0.1",
|
|
61
|
+
"@zapier/zapier-sdk-cli-login": "workspace:*",
|
|
52
62
|
"tsup": "^8.5.0",
|
|
53
63
|
"typescript": "^5.8.3",
|
|
54
|
-
"vitest": "^3.2.3"
|
|
55
|
-
"@zapier/zapier-sdk-cli-login": "0.3.7"
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"build": "tsup",
|
|
59
|
-
"clean": "rm -rf dist",
|
|
60
|
-
"rebuild": "pnpm clean && pnpm build",
|
|
61
|
-
"dev": "tsc --watch",
|
|
62
|
-
"typecheck": "tsc --project tsconfig.build.json --noEmit",
|
|
63
|
-
"test": "vitest"
|
|
64
|
+
"vitest": "^3.2.3"
|
|
64
65
|
}
|
|
65
|
-
}
|
|
66
|
+
}
|
package/dist/api/auth.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication Utilities
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for handling authentication tokens,
|
|
5
|
-
* including JWT detection and authorization header generation.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isJwt(token: string): boolean;
|
|
8
|
-
export declare function getAuthorizationHeader(token: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Extract user IDs from JWT token
|
|
11
|
-
* Decodes the JWT payload and extracts customuser_id and account_id
|
|
12
|
-
* Handles nested JWTs for service tokens
|
|
13
|
-
* Returns null values on any failure (silent-by-design)
|
|
14
|
-
*/
|
|
15
|
-
export declare function extractUserIdsFromJwt(token: string): {
|
|
16
|
-
customuser_id: number | null;
|
|
17
|
-
account_id: number | null;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=auth.d.ts.map
|
package/dist/api/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/api/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW5C;AAaD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG;IACpD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAwCA"}
|
package/dist/api/auth.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication Utilities
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for handling authentication tokens,
|
|
5
|
-
* including JWT detection and authorization header generation.
|
|
6
|
-
*/
|
|
7
|
-
export function isJwt(token) {
|
|
8
|
-
// JWT tokens have exactly 3 parts separated by dots
|
|
9
|
-
const parts = token.split(".");
|
|
10
|
-
if (parts.length !== 3) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
// Each part should be base64url encoded (no padding)
|
|
14
|
-
// Basic validation - each part should be non-empty and contain valid base64url characters
|
|
15
|
-
const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
|
|
16
|
-
return parts.every((part) => part.length > 0 && base64UrlPattern.test(part));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parse a JWT token into its three parts
|
|
20
|
-
* Returns the parts array if valid, null otherwise
|
|
21
|
-
*/
|
|
22
|
-
function parseJwt(token) {
|
|
23
|
-
if (!isJwt(token)) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return token.split(".");
|
|
27
|
-
}
|
|
28
|
-
export function getAuthorizationHeader(token) {
|
|
29
|
-
// Check if token is a JWT (has 3 parts separated by dots)
|
|
30
|
-
if (isJwt(token)) {
|
|
31
|
-
return `JWT ${token}`;
|
|
32
|
-
}
|
|
33
|
-
// Default to Bearer for other token types
|
|
34
|
-
return `Bearer ${token}`;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Extract user IDs from JWT token
|
|
38
|
-
* Decodes the JWT payload and extracts customuser_id and account_id
|
|
39
|
-
* Handles nested JWTs for service tokens
|
|
40
|
-
* Returns null values on any failure (silent-by-design)
|
|
41
|
-
*/
|
|
42
|
-
export function extractUserIdsFromJwt(token) {
|
|
43
|
-
const parts = parseJwt(token);
|
|
44
|
-
if (!parts) {
|
|
45
|
-
return { customuser_id: null, account_id: null };
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
|
|
49
|
-
let actualPayload = payload;
|
|
50
|
-
if (payload.sub_type === "service" && payload.njwt) {
|
|
51
|
-
const nestedParts = payload.njwt.split(".");
|
|
52
|
-
if (nestedParts.length === 3) {
|
|
53
|
-
actualPayload = JSON.parse(Buffer.from(nestedParts[1], "base64url").toString("utf-8"));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const accountId = actualPayload["zap:acc"] != null
|
|
57
|
-
? parseInt(String(actualPayload["zap:acc"]), 10)
|
|
58
|
-
: null;
|
|
59
|
-
const customUserId = actualPayload.sub_type === "customuser" && actualPayload.sub != null
|
|
60
|
-
? parseInt(String(actualPayload.sub), 10)
|
|
61
|
-
: null;
|
|
62
|
-
return {
|
|
63
|
-
customuser_id: customUserId !== null && !isNaN(customUserId) ? customUserId : null,
|
|
64
|
-
account_id: accountId !== null && !isNaN(accountId) ? accountId : null,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return { customuser_id: null, account_id: null };
|
|
69
|
-
}
|
|
70
|
-
}
|
package/dist/api/auth.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.test.d.ts","sourceRoot":"","sources":["../../src/api/auth.test.ts"],"names":[],"mappings":""}
|