@atlasauth/backend 0.10.0 → 0.12.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 +18 -0
- package/README.md +55 -0
- package/dist/client/error.d.ts +4 -0
- package/dist/client/error.js +4 -0
- package/dist/client/error.js.map +1 -1
- package/dist/client/index.d.ts +28 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/referrals.d.ts +405 -0
- package/dist/client/referrals.js +70 -0
- package/dist/client/referrals.js.map +1 -0
- package/dist/client/user-hooks.d.ts +58 -0
- package/dist/client/user-hooks.js +21 -0
- package/dist/client/user-hooks.js.map +1 -0
- package/dist/client/users.d.ts +147 -0
- package/dist/client/users.js +24 -0
- package/dist/client/users.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/referral-test-calls.d.ts +71 -0
- package/dist/referral-test-calls.js +70 -0
- package/dist/referral-test-calls.js.map +1 -0
- package/dist/referrals.d.ts +259 -0
- package/dist/referrals.js +134 -0
- package/dist/referrals.js.map +1 -0
- package/dist/testing.d.ts +12 -0
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.referralsResource = referralsResource;
|
|
4
|
+
const request_1 = require("./request");
|
|
5
|
+
function referralsResource(request) {
|
|
6
|
+
return {
|
|
7
|
+
/** `GET /v1/instance/referrals` — settings, connection status and the supported providers. */
|
|
8
|
+
get() {
|
|
9
|
+
return request({ method: 'GET', path: '/v1/instance/referrals' });
|
|
10
|
+
},
|
|
11
|
+
/** `PATCH /v1/instance/referrals` — partial update; secrets are write-only. */
|
|
12
|
+
update(body, idempotencyKey) {
|
|
13
|
+
return request({ method: 'PATCH', path: '/v1/instance/referrals', body, idempotencyKey });
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* `POST /v1/instance/referrals/test` — a signed probe of the platform. `ok`
|
|
17
|
+
* when it answered 2xx or 404; `error.code` `signature_rejected` on 401/403.
|
|
18
|
+
*/
|
|
19
|
+
test() {
|
|
20
|
+
return request({ method: 'POST', path: '/v1/instance/referrals/test' });
|
|
21
|
+
},
|
|
22
|
+
/** `GET /v1/instance/referrals/calls` — the call log, newest first. */
|
|
23
|
+
listCalls(params = {}) {
|
|
24
|
+
return request({ method: 'GET', path: '/v1/instance/referrals/calls', query: { ...params } });
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* `POST /v1/instance/referrals/calls/:id/retry` — retry a failed, retrying
|
|
28
|
+
* or skipped call now (a connection test cannot be retried).
|
|
29
|
+
*/
|
|
30
|
+
retryCall(id, idempotencyKey) {
|
|
31
|
+
return request({
|
|
32
|
+
method: 'POST',
|
|
33
|
+
path: `/v1/instance/referrals/calls/${(0, request_1.enc)(id)}/retry`,
|
|
34
|
+
idempotencyKey,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
/** `POST /v1/instance/referrals/calls/retry_failed` — re-queue every failed call (not tests) to send now. */
|
|
38
|
+
retryFailed(filter = {}, idempotencyKey) {
|
|
39
|
+
return request({ method: 'POST', path: '/v1/instance/referrals/calls/retry_failed', body: filter, idempotencyKey });
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/instance/referrals/simulate` — send a sign-up call for a fake
|
|
43
|
+
* user (`atlas_test_<random>`, never stored) with an optional code, and
|
|
44
|
+
* return what the platform answered.
|
|
45
|
+
*/
|
|
46
|
+
simulate(body = {}) {
|
|
47
|
+
return request({ method: 'POST', path: '/v1/instance/referrals/simulate', body });
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* `POST /v1/instance/referrals/backfill` — queue sign-up calls for existing
|
|
51
|
+
* users with their real sign-up time. Referrals must be on (`422
|
|
52
|
+
* REFERRALS_NOT_CONFIGURED` otherwise). Returns the job; poll {@link getBackfill}.
|
|
53
|
+
*/
|
|
54
|
+
backfill(body, idempotencyKey) {
|
|
55
|
+
return request({ method: 'POST', path: '/v1/instance/referrals/backfill', body, idempotencyKey });
|
|
56
|
+
},
|
|
57
|
+
/** `GET /v1/instance/referrals/backfill/:id`. */
|
|
58
|
+
getBackfill(id) {
|
|
59
|
+
return request({ method: 'GET', path: `/v1/instance/referrals/backfill/${(0, request_1.enc)(id)}` });
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* `GET /v1/users/:id/referral` — the stored result for one user (who
|
|
63
|
+
* referred them, how, their own code), with no call to the platform.
|
|
64
|
+
*/
|
|
65
|
+
getForUser(userId) {
|
|
66
|
+
return request({ method: 'GET', path: `/v1/users/${(0, request_1.enc)(userId)}/referral` });
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=referrals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referrals.js","sourceRoot":"","sources":["../../src/client/referrals.ts"],"names":[],"mappings":";;AAiWA,8CAmEC;AApaD,uCAAgD;AAiWhD,SAAgB,iBAAiB,CAAC,OAAkB;IAClD,OAAO;QACL,8FAA8F;QAC9F,GAAG;YACD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;QACpE,CAAC;QACD,+EAA+E;QAC/E,MAAM,CAAC,IAAgC,EAAE,cAAuB;YAC9D,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD;;;WAGG;QACH,IAAI;YACF,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,uE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,EAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { RequestFn } from './request';
|
|
2
|
+
/**
|
|
3
|
+
* The `before_user_create` hook: just before Atlas creates a user from an
|
|
4
|
+
* interactive sign-up, it calls your endpoint (signed exactly like a webhook:
|
|
5
|
+
* `atlas-id`, `atlas-timestamp`, `atlas-signature`, verify with
|
|
6
|
+
* {@link verifyWebhook}) with an event of type `user.before_create`, and stamps
|
|
7
|
+
* the `external_id` and metadata you answer. A referral call then goes out
|
|
8
|
+
* with your id. Slow or failing hooks never block a sign-up.
|
|
9
|
+
*
|
|
10
|
+
* Answer `{ external_id?, public_metadata?, private_metadata?, unsafe_metadata? }`.
|
|
11
|
+
*/
|
|
12
|
+
export interface BeforeUserCreateHook {
|
|
13
|
+
object: 'before_user_create_hook';
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
url: string | null;
|
|
16
|
+
/** The secret is write-only. */
|
|
17
|
+
signing_secret_set: boolean;
|
|
18
|
+
/** At most 5000, default 3000. */
|
|
19
|
+
timeout_ms: number;
|
|
20
|
+
/** The last call Atlas made to the hook. */
|
|
21
|
+
last_call: {
|
|
22
|
+
at: number;
|
|
23
|
+
status: string | null;
|
|
24
|
+
error: string | null;
|
|
25
|
+
} | null;
|
|
26
|
+
updated_at: number | null;
|
|
27
|
+
}
|
|
28
|
+
export interface UpdateBeforeUserCreateHookBody {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
/** https (http only for localhost on a development instance); `null` clears. */
|
|
31
|
+
url?: string | null;
|
|
32
|
+
/** Write-only; `null` clears. */
|
|
33
|
+
signing_secret?: string | null;
|
|
34
|
+
timeout_ms?: number;
|
|
35
|
+
}
|
|
36
|
+
/** `POST …/test`: a sample draft sent to the hook; nothing is stored. */
|
|
37
|
+
export interface BeforeUserCreateHookTest {
|
|
38
|
+
ok: boolean;
|
|
39
|
+
latency_ms: number;
|
|
40
|
+
answer?: {
|
|
41
|
+
external_id: string | null;
|
|
42
|
+
public_metadata: Record<string, unknown> | null;
|
|
43
|
+
private_metadata_set: boolean;
|
|
44
|
+
unsafe_metadata: Record<string, unknown> | null;
|
|
45
|
+
};
|
|
46
|
+
error?: {
|
|
47
|
+
code: string;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare function userHooksResource(request: RequestFn): {
|
|
52
|
+
/** `GET /v1/instance/hooks/before_user_create`. */
|
|
53
|
+
getBeforeUserCreate(): Promise<BeforeUserCreateHook>;
|
|
54
|
+
/** `PATCH /v1/instance/hooks/before_user_create` — partial; the secret is write-only. */
|
|
55
|
+
updateBeforeUserCreate(body: UpdateBeforeUserCreateHookBody): Promise<BeforeUserCreateHook>;
|
|
56
|
+
/** `POST /v1/instance/hooks/before_user_create/test`. */
|
|
57
|
+
testBeforeUserCreate(): Promise<BeforeUserCreateHookTest>;
|
|
58
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userHooksResource = userHooksResource;
|
|
4
|
+
const PATH = '/v1/instance/hooks/before_user_create';
|
|
5
|
+
function userHooksResource(request) {
|
|
6
|
+
return {
|
|
7
|
+
/** `GET /v1/instance/hooks/before_user_create`. */
|
|
8
|
+
getBeforeUserCreate() {
|
|
9
|
+
return request({ method: 'GET', path: PATH });
|
|
10
|
+
},
|
|
11
|
+
/** `PATCH /v1/instance/hooks/before_user_create` — partial; the secret is write-only. */
|
|
12
|
+
updateBeforeUserCreate(body) {
|
|
13
|
+
return request({ method: 'PATCH', path: PATH, body });
|
|
14
|
+
},
|
|
15
|
+
/** `POST /v1/instance/hooks/before_user_create/test`. */
|
|
16
|
+
testBeforeUserCreate() {
|
|
17
|
+
return request({ method: 'POST', path: `${PATH}/test` });
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=user-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-hooks.js","sourceRoot":"","sources":["../../src/client/user-hooks.ts"],"names":[],"mappings":";;AAkDA,8CAeC;AAjBD,MAAM,IAAI,GAAG,uCAAuC,CAAC;AAErD,SAAgB,iBAAiB,CAAC,OAAkB;IAClD,OAAO;QACL,mDAAmD;QACnD,mBAAmB;YACjB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,yFAAyF;QACzF,sBAAsB,CAAC,IAAoC;YACzD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,yDAAyD;QACzD,oBAAoB;YAClB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/client/users.d.ts
CHANGED
|
@@ -22,6 +22,121 @@ export interface User {
|
|
|
22
22
|
* the one you hold. (Absent from servers older than this field.)
|
|
23
23
|
*/
|
|
24
24
|
version?: number;
|
|
25
|
+
/**
|
|
26
|
+
* How the user arrived through a referral program, when the instance has
|
|
27
|
+
* referral attribution on and the platform matched a referrer; null when not
|
|
28
|
+
* referred, not answered yet, or referrals are off. (Absent from servers
|
|
29
|
+
* older than this field.)
|
|
30
|
+
*/
|
|
31
|
+
referral?: UserReferral | null;
|
|
32
|
+
/** The user's own referral code, when they are a referrer. */
|
|
33
|
+
referral_code?: string | null;
|
|
34
|
+
/** The user's own referral link, when they are a referrer. */
|
|
35
|
+
referral_link?: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** The inbound referral the referral platform matched for a user. */
|
|
38
|
+
export interface UserReferral {
|
|
39
|
+
/** The platform's id for the referring partner. */
|
|
40
|
+
partner_id: string | null;
|
|
41
|
+
/** The referrer as the platform knows them (your `external_id` for that user, or their Atlas id). */
|
|
42
|
+
referrer_external_id: string | null;
|
|
43
|
+
/** The referrer's Atlas user id, when they are a user of this instance. */
|
|
44
|
+
referrer_user_id: string | null;
|
|
45
|
+
/** How the platform matched the referral, e.g. `code`, `click`, `coupon`. */
|
|
46
|
+
matched_via: string | null;
|
|
47
|
+
/**
|
|
48
|
+
* The attribution status: `pending` (the platform has not answered yet),
|
|
49
|
+
* `attributed`, `none`, `failed`, `held` or `flagged`. Servers before
|
|
50
|
+
* referral attribution v2 sent the platform's own status here; that is now
|
|
51
|
+
* `referral_status`.
|
|
52
|
+
*/
|
|
53
|
+
status: string | null;
|
|
54
|
+
/** The referrer as the platform knows them. Same value as `referrer_external_id`. */
|
|
55
|
+
partner_external_ref?: string | null;
|
|
56
|
+
/** The platform's own status for the referral, e.g. `active`. */
|
|
57
|
+
referral_status?: string | null;
|
|
58
|
+
/** The platform's reasoning notes (why it matched, or why not). */
|
|
59
|
+
notes?: string[] | null;
|
|
60
|
+
/** The risk level Atlas assessed at sign-up, when one was. */
|
|
61
|
+
risk_level?: 'low' | 'medium' | 'high' | null;
|
|
62
|
+
/** An admin marked the referral fraudulent (`users.flagReferral`). */
|
|
63
|
+
flagged?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An imported referral on `users.create`: how the user arrived. With referral
|
|
67
|
+
* attribution on, the user is reported to the referral platform. Each id is
|
|
68
|
+
* 3-64 characters of `A-Z a-z 0-9 _ -`.
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateUserReferralInput {
|
|
71
|
+
code?: string;
|
|
72
|
+
click_id?: string;
|
|
73
|
+
anon_id?: string;
|
|
74
|
+
}
|
|
75
|
+
/** `POST /v1/users/:id/referral/flag`. */
|
|
76
|
+
export interface UserReferralFlag {
|
|
77
|
+
object: 'user_referral';
|
|
78
|
+
user_id: string;
|
|
79
|
+
/** `flagged` after this call. */
|
|
80
|
+
status: string;
|
|
81
|
+
flagged: boolean;
|
|
82
|
+
flag_reason: string | null;
|
|
83
|
+
/** Epoch ms. */
|
|
84
|
+
flagged_at: number | null;
|
|
85
|
+
risk_level: 'low' | 'medium' | 'high' | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The `data` of a `user.referral_attributed` webhook: the referral platform
|
|
89
|
+
* answered after `user.created` was sent.
|
|
90
|
+
*/
|
|
91
|
+
export interface UserReferralAttributedEvent {
|
|
92
|
+
object: 'user_referral';
|
|
93
|
+
user_id: string;
|
|
94
|
+
/** `attributed`, `not_referred`, `failed`, … (`not_referred`: the platform found no referrer). */
|
|
95
|
+
attribution_status: string;
|
|
96
|
+
referral: UserReferral | null;
|
|
97
|
+
referral_code: string | null;
|
|
98
|
+
referral_link: string | null;
|
|
99
|
+
/** Epoch ms. */
|
|
100
|
+
signed_up_at: number;
|
|
101
|
+
updated_at: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The `data` of a `user.referral_resolved` webhook: a referral call that was
|
|
105
|
+
* still pending when `user.created` was sent has a final result (attributed,
|
|
106
|
+
* none or failed). `user.referral_attributed` still fires too when attributed.
|
|
107
|
+
*/
|
|
108
|
+
export type UserReferralResolvedEvent = UserReferralAttributedEvent;
|
|
109
|
+
/**
|
|
110
|
+
* `GET /v1/users/:id/referral`: the stored result of the user's referral
|
|
111
|
+
* calls, with no call to the platform. 404 when the user was never reported.
|
|
112
|
+
*/
|
|
113
|
+
export interface UserReferralResult {
|
|
114
|
+
object: 'user_referral';
|
|
115
|
+
user_id: string;
|
|
116
|
+
/** `pending`, `attributed`, `none`, `failed`, `held` or `flagged`. */
|
|
117
|
+
status: 'pending' | 'attributed' | 'none' | 'failed' | 'held' | 'flagged';
|
|
118
|
+
/** The id Atlas reports the user under: their `external_id`, else the Atlas user id. */
|
|
119
|
+
customer_ref: string;
|
|
120
|
+
partner_id: string | null;
|
|
121
|
+
/** The referrer as the platform knows them. */
|
|
122
|
+
partner_external_ref: string | null;
|
|
123
|
+
referrer_user_id: string | null;
|
|
124
|
+
matched_via: string | null;
|
|
125
|
+
/** The platform's own status for the referral. */
|
|
126
|
+
referral_status: string | null;
|
|
127
|
+
/** The platform's reasoning notes. */
|
|
128
|
+
notes: string[];
|
|
129
|
+
referral_code: string | null;
|
|
130
|
+
referral_link: string | null;
|
|
131
|
+
/** The referral captured at sign-up, as sent (camelCase). */
|
|
132
|
+
context: Record<string, unknown> | null;
|
|
133
|
+
risk_level: 'low' | 'medium' | 'high' | null;
|
|
134
|
+
flagged: boolean;
|
|
135
|
+
/** Why the call is held, while `held`. */
|
|
136
|
+
hold_reason: string | null;
|
|
137
|
+
/** Epoch ms. */
|
|
138
|
+
signed_up_at: number;
|
|
139
|
+
updated_at: number;
|
|
25
140
|
}
|
|
26
141
|
export interface EmailAddress {
|
|
27
142
|
object: 'email_address';
|
|
@@ -75,12 +190,27 @@ export interface CreateUserBody {
|
|
|
75
190
|
* guarantees no email, SMS or push is sent as a consequence of the create.
|
|
76
191
|
*/
|
|
77
192
|
notify?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Import a referral (how the user arrived). With referral attribution on,
|
|
195
|
+
* the user is reported to the referral platform.
|
|
196
|
+
*/
|
|
197
|
+
referral?: CreateUserReferralInput;
|
|
198
|
+
/** The user's own referral code; unique per instance (`409 REFERRAL_CODE_TAKEN`). */
|
|
199
|
+
referral_code?: string;
|
|
78
200
|
}
|
|
79
201
|
export interface UpdateUserBody {
|
|
80
202
|
first_name?: string;
|
|
81
203
|
last_name?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Your own id for the user; `null` clears. With referral attribution on, a
|
|
206
|
+
* change after sign-up is forwarded to the referral platform as an alias,
|
|
207
|
+
* so events under the new id still match.
|
|
208
|
+
*/
|
|
209
|
+
external_id?: string | null;
|
|
82
210
|
public_metadata?: Metadata;
|
|
83
211
|
private_metadata?: Metadata;
|
|
212
|
+
/** The user's own referral code; `null` clears. Unique per instance (`409 REFERRAL_CODE_TAKEN`). */
|
|
213
|
+
referral_code?: string | null;
|
|
84
214
|
}
|
|
85
215
|
export interface ReplaceUserMetadataBody {
|
|
86
216
|
public_metadata?: Metadata;
|
|
@@ -93,6 +223,13 @@ export declare function usersResource(request: RequestFn): {
|
|
|
93
223
|
get(id: string): Promise<User>;
|
|
94
224
|
create(body: CreateUserBody, idempotencyKey?: string): Promise<User>;
|
|
95
225
|
update(id: string, body: UpdateUserBody): Promise<User>;
|
|
226
|
+
/**
|
|
227
|
+
* Set (or clear with `null`) the user's `external_id`: `PATCH
|
|
228
|
+
* /v1/users/:id`. With referral attribution on, Atlas forwards the change
|
|
229
|
+
* to the referral platform as an alias (old id, or the Atlas user id, to
|
|
230
|
+
* the new one), so billing events under your id earn the referrer.
|
|
231
|
+
*/
|
|
232
|
+
setExternalId(id: string, externalId: string | null): Promise<User>;
|
|
96
233
|
/** `PUT /v1/users/:id/metadata` — replaces the named bags wholesale. */
|
|
97
234
|
replaceMetadata(id: string, body: ReplaceUserMetadataBody): Promise<User>;
|
|
98
235
|
ban(id: string): Promise<User>;
|
|
@@ -101,6 +238,16 @@ export declare function usersResource(request: RequestFn): {
|
|
|
101
238
|
duration_in_seconds?: number;
|
|
102
239
|
}): Promise<User>;
|
|
103
240
|
unlock(id: string): Promise<User>;
|
|
241
|
+
/**
|
|
242
|
+
* `POST /v1/users/:id/referral/flag` — mark the user's referral fraudulent.
|
|
243
|
+
* The referral reads `flagged: true`, the referral platform is sent a
|
|
244
|
+
* `fraud_confirmed` signal (when referrals are on) and the action is
|
|
245
|
+
* audited. The user's account is not changed. 404 when the user has no
|
|
246
|
+
* referral. `reason` (at most 500 characters) is sent to the platform.
|
|
247
|
+
*/
|
|
248
|
+
flagReferral(id: string, body?: {
|
|
249
|
+
reason?: string;
|
|
250
|
+
}, idempotencyKey?: string): Promise<UserReferralFlag>;
|
|
104
251
|
delete(id: string): Promise<DeletedObject>;
|
|
105
252
|
resetMfa(id: string): Promise<{
|
|
106
253
|
object: "user";
|
package/dist/client/users.js
CHANGED
|
@@ -17,6 +17,15 @@ function usersResource(request) {
|
|
|
17
17
|
update(id, body) {
|
|
18
18
|
return request({ method: 'PATCH', path: `/v1/users/${(0, request_1.enc)(id)}`, body });
|
|
19
19
|
},
|
|
20
|
+
/**
|
|
21
|
+
* Set (or clear with `null`) the user's `external_id`: `PATCH
|
|
22
|
+
* /v1/users/:id`. With referral attribution on, Atlas forwards the change
|
|
23
|
+
* to the referral platform as an alias (old id, or the Atlas user id, to
|
|
24
|
+
* the new one), so billing events under your id earn the referrer.
|
|
25
|
+
*/
|
|
26
|
+
setExternalId(id, externalId) {
|
|
27
|
+
return request({ method: 'PATCH', path: `/v1/users/${(0, request_1.enc)(id)}`, body: { external_id: externalId } });
|
|
28
|
+
},
|
|
20
29
|
/** `PUT /v1/users/:id/metadata` — replaces the named bags wholesale. */
|
|
21
30
|
replaceMetadata(id, body) {
|
|
22
31
|
return request({ method: 'PUT', path: `/v1/users/${(0, request_1.enc)(id)}/metadata`, body });
|
|
@@ -33,6 +42,21 @@ function usersResource(request) {
|
|
|
33
42
|
unlock(id) {
|
|
34
43
|
return request({ method: 'POST', path: `/v1/users/${(0, request_1.enc)(id)}/unlock` });
|
|
35
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/users/:id/referral/flag` — mark the user's referral fraudulent.
|
|
47
|
+
* The referral reads `flagged: true`, the referral platform is sent a
|
|
48
|
+
* `fraud_confirmed` signal (when referrals are on) and the action is
|
|
49
|
+
* audited. The user's account is not changed. 404 when the user has no
|
|
50
|
+
* referral. `reason` (at most 500 characters) is sent to the platform.
|
|
51
|
+
*/
|
|
52
|
+
flagReferral(id, body = {}, idempotencyKey) {
|
|
53
|
+
return request({
|
|
54
|
+
method: 'POST',
|
|
55
|
+
path: `/v1/users/${(0, request_1.enc)(id)}/referral/flag`,
|
|
56
|
+
body,
|
|
57
|
+
idempotencyKey,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
36
60
|
delete(id) {
|
|
37
61
|
return request({ method: 'DELETE', path: `/v1/users/${(0, request_1.enc)(id)}` });
|
|
38
62
|
},
|
package/dist/client/users.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/client/users.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/client/users.ts"],"names":[],"mappings":";;AAsOA,sCAucC;AA7qBD,uCAAgD;AAsOhD,SAAgB,aAAa,CAAC,OAAkB;IAC9C,OAAO;QACL,0CAA0C;QAC1C,IAAI,CAAC,SAA0B,EAAE;YAC/B,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,GAAG,CAAC,EAAU;YACZ,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,MAAM,CAAC,IAAoB,EAAE,cAAuB;YAClD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,MAAM,CAAC,EAAU,EAAE,IAAoB;YACrC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD;;;;;WAKG;QACH,aAAa,CAAC,EAAU,EAAE,UAAyB;YACjD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,IAAA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,CAAC;YACL,CAAC;YACD,MAAM,CACJ,EAAU,EACV,OAAe;gBAEf,OAAO,OAAO,CAAC;oBACb,MAAM,EAAE,QAAQ;oBAChB,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,EAAE,CAAC,kBAAkB,IAAA,aAAG,EAAC,OAAO,CAAC,EAAE;iBAC3D,CAAC,CAAC;YACL,CAAC;SACF;QACD,8BAA8B;QAC9B,WAAW,EAAE;YACX;;;eAGG;YACH,QAAQ,CAAC,EAAU,EAAE,IAA8B;gBACjD,OAAO,OAAO,CAAC;oBACb,MAAM,EAAE,MAAM;oBACd,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,EAAE,CAAC,qBAAqB;oBAC/C,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,14 @@ export type { LogoutReplayStore, LogoutTokenCheckOptions, LogoutTokenClaims, Log
|
|
|
7
7
|
export { AtlasOidcError, OIDC_FLOW_COOKIE, OIDC_FLOW_MAX_AGE_SECONDS, oidc, oidcCallback, oidcClearCookie, oidcLogoutUrl, oidcStart, oidcVerifyIdToken, resetOidcCaches, } from './oidc';
|
|
8
8
|
export type { AtlasOidc, AtlasOidcErrorCode, OidcCallbackOptions, OidcClientAuth, OidcIdentity, OidcLogoutUrlOptions, OidcStartOptions, OidcStartResult, VerifyIdTokenOptions, } from './oidc';
|
|
9
9
|
export * from './webhooks';
|
|
10
|
+
export * from './referrals';
|
|
10
11
|
export { createAtlasClient } from './client';
|
|
11
12
|
export type { AtlasClient } from './client';
|
|
12
13
|
export * from './client';
|
|
13
14
|
export { createTestIssuer, TEST_TOKEN_TAMPERS } from './testing';
|
|
14
15
|
export type { TestIssuer, CreateTestIssuerOptions, MintIdTokenOptions, TestAuthorizeOptions, TestAuthorizeResult, TestTokenTamper, } from './testing';
|
|
16
|
+
export { signAtlasReferralCall, signReferallyCall, referallySignature, referralEmailHash, REFERALLY_API_VERSION, } from './referral-test-calls';
|
|
17
|
+
export type { AtlasReferralCallOptions, ReferallyCallOptions, ReferallyCallOp, SignedReferralCall, } from './referral-test-calls';
|
|
15
18
|
export { verifyPCActn } from './pca/verify';
|
|
16
19
|
export type { PcaVerdict, PcaContext, VerifyPCActnOptions } from './pca/verify';
|
|
17
20
|
export { requirePCA, defaultExtract, memoryPcaStore } from './pca/require-pca';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = exports.verifyPCActn = exports.TEST_TOKEN_TAMPERS = exports.createTestIssuer = exports.createAtlasClient = exports.resetOidcCaches = exports.oidcVerifyIdToken = exports.oidcStart = exports.oidcLogoutUrl = exports.oidcClearCookie = exports.oidcCallback = exports.oidc = exports.OIDC_FLOW_MAX_AGE_SECONDS = exports.OIDC_FLOW_COOKIE = exports.AtlasOidcError = exports.verifyLogoutToken = exports.memoryLogoutReplayStore = exports.LogoutTokenVerifier = exports.LOGOUT_TOKEN_MAX_AGE_SECONDS = exports.LOGOUT_TOKEN_CLOCK_SKEW_SECONDS = exports.BACKCHANNEL_LOGOUT_EVENT = exports.instanceIdFromPublishableKey = exports.discoveryUrlFor = exports.JwksDiscovery = exports.DiscoveryError = void 0;
|
|
17
|
+
exports.memoryPcaStore = exports.defaultExtract = exports.requirePCA = exports.verifyPCActn = exports.REFERALLY_API_VERSION = exports.referralEmailHash = exports.referallySignature = exports.signReferallyCall = exports.signAtlasReferralCall = exports.TEST_TOKEN_TAMPERS = exports.createTestIssuer = exports.createAtlasClient = exports.resetOidcCaches = exports.oidcVerifyIdToken = exports.oidcStart = exports.oidcLogoutUrl = exports.oidcClearCookie = exports.oidcCallback = exports.oidc = exports.OIDC_FLOW_MAX_AGE_SECONDS = exports.OIDC_FLOW_COOKIE = exports.AtlasOidcError = exports.verifyLogoutToken = exports.memoryLogoutReplayStore = exports.LogoutTokenVerifier = exports.LOGOUT_TOKEN_MAX_AGE_SECONDS = exports.LOGOUT_TOKEN_CLOCK_SKEW_SECONDS = exports.BACKCHANNEL_LOGOUT_EVENT = exports.instanceIdFromPublishableKey = exports.discoveryUrlFor = exports.JwksDiscovery = exports.DiscoveryError = void 0;
|
|
18
18
|
// §7.3 token verification — the original surface, unchanged.
|
|
19
19
|
__exportStar(require("./jwks-cache"), exports);
|
|
20
20
|
// OIDC discovery of the JWKS URL when only `issuer` is configured.
|
|
@@ -48,6 +48,8 @@ Object.defineProperty(exports, "oidcVerifyIdToken", { enumerable: true, get: fun
|
|
|
48
48
|
Object.defineProperty(exports, "resetOidcCaches", { enumerable: true, get: function () { return oidc_1.resetOidcCaches; } });
|
|
49
49
|
// §12.2 inbound webhook verification for consumers.
|
|
50
50
|
__exportStar(require("./webhooks"), exports);
|
|
51
|
+
// The Atlas referral protocol, for a referral platform receiving Atlas's signed calls.
|
|
52
|
+
__exportStar(require("./referrals"), exports);
|
|
51
53
|
// The typed management client for the secret-key Backend API.
|
|
52
54
|
var client_1 = require("./client");
|
|
53
55
|
Object.defineProperty(exports, "createAtlasClient", { enumerable: true, get: function () { return client_1.createAtlasClient; } });
|
|
@@ -58,6 +60,12 @@ __exportStar(require("./client"), exports);
|
|
|
58
60
|
var testing_1 = require("./testing");
|
|
59
61
|
Object.defineProperty(exports, "createTestIssuer", { enumerable: true, get: function () { return testing_1.createTestIssuer; } });
|
|
60
62
|
Object.defineProperty(exports, "TEST_TOKEN_TAMPERS", { enumerable: true, get: function () { return testing_1.TEST_TOKEN_TAMPERS; } });
|
|
63
|
+
var referral_test_calls_1 = require("./referral-test-calls");
|
|
64
|
+
Object.defineProperty(exports, "signAtlasReferralCall", { enumerable: true, get: function () { return referral_test_calls_1.signAtlasReferralCall; } });
|
|
65
|
+
Object.defineProperty(exports, "signReferallyCall", { enumerable: true, get: function () { return referral_test_calls_1.signReferallyCall; } });
|
|
66
|
+
Object.defineProperty(exports, "referallySignature", { enumerable: true, get: function () { return referral_test_calls_1.referallySignature; } });
|
|
67
|
+
Object.defineProperty(exports, "referralEmailHash", { enumerable: true, get: function () { return referral_test_calls_1.referralEmailHash; } });
|
|
68
|
+
Object.defineProperty(exports, "REFERALLY_API_VERSION", { enumerable: true, get: function () { return referral_test_calls_1.REFERALLY_API_VERSION; } });
|
|
61
69
|
// Proof-Carrying Authority (agentic auth): offline verifier + framework-agnostic guard,
|
|
62
70
|
// beside the session-token verifier above.
|
|
63
71
|
var verify_1 = require("./pca/verify");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6DAA6D;AAC7D,+CAA6B;AAC7B,mEAAmE;AACnE,yCAA2G;AAAlG,2GAAA,cAAc,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,yHAAA,4BAA4B,OAAA;AACrF,2CAAyB;AACzB,8CAA4B;AAE5B,6EAA6E;AAC7E,+CAOwB;AANtB,wHAAA,wBAAwB,OAAA;AACxB,+HAAA,+BAA+B,OAAA;AAC/B,4HAAA,4BAA4B,OAAA;AAC5B,mHAAA,mBAAmB,OAAA;AACnB,uHAAA,uBAAuB,OAAA;AACvB,iHAAA,iBAAiB,OAAA;AAUnB,sEAAsE;AACtE,iFAAiF;AACjF,+BAWgB;AAVd,sGAAA,cAAc,OAAA;AACd,wGAAA,gBAAgB,OAAA;AAChB,iHAAA,yBAAyB,OAAA;AACzB,4FAAA,IAAI,OAAA;AACJ,oGAAA,YAAY,OAAA;AACZ,uGAAA,eAAe,OAAA;AACf,qGAAA,aAAa,OAAA;AACb,iGAAA,SAAS,OAAA;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iE;AACjE,qCAAiE;AAAxD,2GAAA,gBAAgB,OAAA;AAAE,6GAAA,kBAAkB,OAAA;AAS7C,6DAM+B;AAL7B,4HAAA,qBAAqB,OAAA;AACrB,wHAAA,iBAAiB,OAAA;AACjB,yHAAA,kBAAkB,OAAA;AAClB,wHAAA,iBAAiB,OAAA;AACjB,4HAAA,qBAAqB,OAAA;AASvB,wFAAwF;AACxF,2CAA2C;AAC3C,uCAA4C;AAAnC,sGAAA,YAAY,OAAA;AAErB,iDAA+E;AAAtE,yGAAA,UAAU,OAAA;AAAE,6GAAA,cAAc,OAAA;AAAE,6GAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ReferralOp } from './referrals';
|
|
2
|
+
/**
|
|
3
|
+
* Signed referral calls for an app's own test suite: send exactly what an
|
|
4
|
+
* Atlas instance would send to a referral platform, against a platform you run
|
|
5
|
+
* locally, with no Atlas instance involved. Two wire formats:
|
|
6
|
+
*
|
|
7
|
+
* - the Atlas referral protocol (provider `webhook`): every call is a signed
|
|
8
|
+
* `POST {base}/<endpoint>` with `op` and `customerRef` in the body, signed
|
|
9
|
+
* like Atlas webhooks (`atlas-id`, `atlas-timestamp`, `atlas-signature`);
|
|
10
|
+
* - Referally (provider `referally`): `{base}/v1/auth/connections/{id}/…`,
|
|
11
|
+
* signed with `x-referally-signature: t=<unix s>,v1=<hex HMAC-SHA256>` over
|
|
12
|
+
* `"{t}.{payload}"`, where payload is the raw body for POST and the raw
|
|
13
|
+
* query string for GET.
|
|
14
|
+
*
|
|
15
|
+
* Both are also on {@link TestIssuer} (`referralCall`, `referallyCall`) with
|
|
16
|
+
* the issuer's clock.
|
|
17
|
+
*/
|
|
18
|
+
/** A ready-to-send signed call. `request()` builds a Fetch `Request`. */
|
|
19
|
+
export interface SignedReferralCall {
|
|
20
|
+
url: string;
|
|
21
|
+
method: 'POST' | 'GET';
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
/** The exact signed body (absent on GET). */
|
|
24
|
+
body?: string;
|
|
25
|
+
request(): Request;
|
|
26
|
+
}
|
|
27
|
+
/** sha256 hex of the lower-cased, trimmed email, as Atlas sends `emailHash`. */
|
|
28
|
+
export declare function referralEmailHash(email: string | null | undefined): string | null;
|
|
29
|
+
export interface AtlasReferralCallOptions {
|
|
30
|
+
/** The platform's base URL, as configured on the instance (`endpoint_url`). */
|
|
31
|
+
baseUrl: string;
|
|
32
|
+
/** The instance's signing secret for the connection. */
|
|
33
|
+
secret: string;
|
|
34
|
+
op: ReferralOp;
|
|
35
|
+
/** The rest of the body (`customerRef` and the op's fields); `op` is added. */
|
|
36
|
+
payload: {
|
|
37
|
+
customerRef: string;
|
|
38
|
+
} & Record<string, unknown>;
|
|
39
|
+
/** The call id (`atlas-id`), the same on every retry of one call. Default: random. */
|
|
40
|
+
callId?: string;
|
|
41
|
+
/** Epoch ms. Default: now. */
|
|
42
|
+
now?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A call in the Atlas referral protocol, signed exactly as an Atlas instance signs it. */
|
|
45
|
+
export declare function signAtlasReferralCall(options: AtlasReferralCallOptions): SignedReferralCall;
|
|
46
|
+
/** The Referally API version Atlas pins on every call (`referally-version`). */
|
|
47
|
+
export declare const REFERALLY_API_VERSION = "2026-10-21";
|
|
48
|
+
/** The Referally connection calls Atlas makes. */
|
|
49
|
+
export type ReferallyCallOp = 'signups' | 'erase' | 'export' | 'aliases' | 'users' | 'ping';
|
|
50
|
+
export interface ReferallyCallOptions {
|
|
51
|
+
/** Your Referally base URL (never hard-code it; read it from config). */
|
|
52
|
+
baseUrl: string;
|
|
53
|
+
/** The Atlas connection id on Referally. */
|
|
54
|
+
connectionId: string;
|
|
55
|
+
/** The connection secret Referally returned when the connection was created. */
|
|
56
|
+
secret: string;
|
|
57
|
+
op: ReferallyCallOp;
|
|
58
|
+
/** The JSON body for POST calls. */
|
|
59
|
+
body?: Record<string, unknown>;
|
|
60
|
+
/** `export` only: the customer to export (sent as `?customerRef=`). */
|
|
61
|
+
customerRef?: string;
|
|
62
|
+
/** Epoch ms. Default: now. */
|
|
63
|
+
now?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The `x-referally-signature` value for a payload: `t=<unix s>,v1=<hex
|
|
67
|
+
* HMAC-SHA256(secret, "{t}.{payload}")>`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function referallySignature(secret: string, payload: string, unixSeconds: number): string;
|
|
70
|
+
/** A Referally connection call, signed exactly as the Atlas `referally` adapter signs it. */
|
|
71
|
+
export declare function signReferallyCall(options: ReferallyCallOptions): SignedReferralCall;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REFERALLY_API_VERSION = void 0;
|
|
4
|
+
exports.referralEmailHash = referralEmailHash;
|
|
5
|
+
exports.signAtlasReferralCall = signAtlasReferralCall;
|
|
6
|
+
exports.referallySignature = referallySignature;
|
|
7
|
+
exports.signReferallyCall = signReferallyCall;
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const referrals_1 = require("./referrals");
|
|
10
|
+
function signed(url, method, headers, body) {
|
|
11
|
+
return {
|
|
12
|
+
url,
|
|
13
|
+
method,
|
|
14
|
+
headers,
|
|
15
|
+
body,
|
|
16
|
+
request: () => new Request(url, { method, headers, body }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const trimBase = (base) => base.replace(/\/+$/, '');
|
|
20
|
+
/** sha256 hex of the lower-cased, trimmed email, as Atlas sends `emailHash`. */
|
|
21
|
+
function referralEmailHash(email) {
|
|
22
|
+
if (!email)
|
|
23
|
+
return null;
|
|
24
|
+
return (0, node_crypto_1.createHash)('sha256').update(email.trim().toLowerCase()).digest('hex');
|
|
25
|
+
}
|
|
26
|
+
/** A call in the Atlas referral protocol, signed exactly as an Atlas instance signs it. */
|
|
27
|
+
function signAtlasReferralCall(options) {
|
|
28
|
+
const id = options.callId ?? `rfc_test_${(0, node_crypto_1.randomBytes)(8).toString('hex')}`;
|
|
29
|
+
const timestamp = options.now ?? Date.now();
|
|
30
|
+
const body = JSON.stringify({ op: options.op, ...options.payload });
|
|
31
|
+
const signature = (0, node_crypto_1.createHmac)('sha256', options.secret).update(`${id}.${timestamp}.${body}`).digest('base64');
|
|
32
|
+
const headers = {
|
|
33
|
+
'content-type': 'application/json',
|
|
34
|
+
'atlas-id': id,
|
|
35
|
+
'atlas-timestamp': String(timestamp),
|
|
36
|
+
'atlas-signature': `v1,${signature}`,
|
|
37
|
+
'idempotency-key': `${options.op}:${options.payload.customerRef}`,
|
|
38
|
+
'user-agent': referrals_1.REFERRAL_PROTOCOL_USER_AGENT,
|
|
39
|
+
[referrals_1.REFERRAL_PROTOCOL_VERSION_HEADER]: referrals_1.REFERRAL_PROTOCOL_VERSION,
|
|
40
|
+
};
|
|
41
|
+
return signed(`${trimBase(options.baseUrl)}/${referrals_1.REFERRAL_OP_ENDPOINTS[options.op]}`, 'POST', headers, body);
|
|
42
|
+
}
|
|
43
|
+
/** The Referally API version Atlas pins on every call (`referally-version`). */
|
|
44
|
+
exports.REFERALLY_API_VERSION = '2026-10-21';
|
|
45
|
+
/**
|
|
46
|
+
* The `x-referally-signature` value for a payload: `t=<unix s>,v1=<hex
|
|
47
|
+
* HMAC-SHA256(secret, "{t}.{payload}")>`.
|
|
48
|
+
*/
|
|
49
|
+
function referallySignature(secret, payload, unixSeconds) {
|
|
50
|
+
const mac = (0, node_crypto_1.createHmac)('sha256', secret).update(`${unixSeconds}.${payload}`).digest('hex');
|
|
51
|
+
return `t=${unixSeconds},v1=${mac}`;
|
|
52
|
+
}
|
|
53
|
+
/** A Referally connection call, signed exactly as the Atlas `referally` adapter signs it. */
|
|
54
|
+
function signReferallyCall(options) {
|
|
55
|
+
const t = Math.floor((options.now ?? Date.now()) / 1000);
|
|
56
|
+
const base = `${trimBase(options.baseUrl)}/v1/auth/connections/${encodeURIComponent(options.connectionId)}/${options.op}`;
|
|
57
|
+
const headers = { 'referally-version': exports.REFERALLY_API_VERSION };
|
|
58
|
+
if (options.op === 'export') {
|
|
59
|
+
if (!options.customerRef)
|
|
60
|
+
throw new Error('signReferallyCall: export needs customerRef.');
|
|
61
|
+
const query = new URLSearchParams({ customerRef: options.customerRef }).toString();
|
|
62
|
+
headers['x-referally-signature'] = referallySignature(options.secret, query, t);
|
|
63
|
+
return signed(`${base}?${query}`, 'GET', headers);
|
|
64
|
+
}
|
|
65
|
+
const body = JSON.stringify(options.body ?? {});
|
|
66
|
+
headers['content-type'] = 'application/json';
|
|
67
|
+
headers['x-referally-signature'] = referallySignature(options.secret, body, t);
|
|
68
|
+
return signed(base, 'POST', headers, body);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=referral-test-calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referral-test-calls.js","sourceRoot":"","sources":["../src/referral-test-calls.ts"],"names":[],"mappings":";;;AAiDA,8CAGC;AAiBD,sDAeC;AA4BD,gDAGC;AAGD,8CAcC;AApID,6CAAkE;AAClE,2CAMqB;AA6BrB,SAAS,MAAM,CAAC,GAAW,EAAE,MAAsB,EAAE,OAA+B,EAAE,IAAa;IACjG,OAAO;QACL,GAAG;QACH,MAAM;QACN,OAAO;QACP,IAAI;QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC3D,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE5D,gFAAgF;AAChF,SAAgB,iBAAiB,CAAC,KAAgC;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAA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