@segment/analytics-browser-actions-rupt 1.1.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.
Files changed (48) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/attach/generated-types.d.ts +9 -0
  3. package/dist/cjs/attach/generated-types.js +3 -0
  4. package/dist/cjs/attach/generated-types.js.map +1 -0
  5. package/dist/cjs/attach/index.d.ts +6 -0
  6. package/dist/cjs/attach/index.js +76 -0
  7. package/dist/cjs/attach/index.js.map +1 -0
  8. package/dist/cjs/attach.types.d.ts +9 -0
  9. package/dist/cjs/attach.types.js +3 -0
  10. package/dist/cjs/attach.types.js.map +1 -0
  11. package/dist/cjs/generated-types.d.ts +7 -0
  12. package/dist/cjs/generated-types.js +3 -0
  13. package/dist/cjs/generated-types.js.map +1 -0
  14. package/dist/cjs/index.d.ts +11 -0
  15. package/dist/cjs/index.js +69 -0
  16. package/dist/cjs/index.js.map +1 -0
  17. package/dist/cjs/types.d.ts +50 -0
  18. package/dist/cjs/types.js +3 -0
  19. package/dist/cjs/types.js.map +1 -0
  20. package/dist/esm/attach/generated-types.d.ts +9 -0
  21. package/dist/esm/attach/generated-types.js +2 -0
  22. package/dist/esm/attach/generated-types.js.map +1 -0
  23. package/dist/esm/attach/index.d.ts +6 -0
  24. package/dist/esm/attach/index.js +74 -0
  25. package/dist/esm/attach/index.js.map +1 -0
  26. package/dist/esm/attach.types.d.ts +9 -0
  27. package/dist/esm/attach.types.js +2 -0
  28. package/dist/esm/attach.types.js.map +1 -0
  29. package/dist/esm/generated-types.d.ts +7 -0
  30. package/dist/esm/generated-types.js +2 -0
  31. package/dist/esm/generated-types.js.map +1 -0
  32. package/dist/esm/index.d.ts +11 -0
  33. package/dist/esm/index.js +65 -0
  34. package/dist/esm/index.js.map +1 -0
  35. package/dist/esm/types.d.ts +50 -0
  36. package/dist/esm/types.js +2 -0
  37. package/dist/esm/types.js.map +1 -0
  38. package/dist/tsconfig.tsbuildinfo +1 -0
  39. package/package.json +25 -0
  40. package/src/__tests__/index.test.ts +28 -0
  41. package/src/attach/__tests__/index.test.ts +77 -0
  42. package/src/attach/generated-types.ts +26 -0
  43. package/src/attach/index.ts +79 -0
  44. package/src/attach.types.ts +26 -0
  45. package/src/generated-types.ts +24 -0
  46. package/src/index.ts +77 -0
  47. package/src/types.ts +76 -0
  48. package/tsconfig.json +9 -0
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @segment/analytics-browser-actions-rupt
2
+
3
+ The Rupt browser action destination for use with @segment/analytics-next.
4
+
5
+ ## License
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2023 Segment
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ ## Contributing
30
+
31
+ All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.
@@ -0,0 +1,9 @@
1
+ export interface Payload {
2
+ account: string;
3
+ email?: string;
4
+ phone?: string;
5
+ metadata?: {
6
+ [k: string]: unknown;
7
+ };
8
+ include_page?: boolean;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/attach/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import { Payload } from 'src/attach.types';
3
+ import { Settings } from 'src/generated-types';
4
+ import Rupt from 'src/types';
5
+ declare const attach: BrowserActionDefinition<Settings, Rupt, Payload>;
6
+ export default attach;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const attach = {
4
+ title: 'Attach Device',
5
+ description: 'Attach a device to an account.',
6
+ defaultSubscription: 'type = "page"',
7
+ platform: 'web',
8
+ fields: {
9
+ account: {
10
+ description: 'The account to attach the device to.',
11
+ label: 'Account',
12
+ type: 'string',
13
+ required: true,
14
+ default: {
15
+ '@path': '$.userId'
16
+ }
17
+ },
18
+ email: {
19
+ description: 'The email of the user to attach the device to.',
20
+ label: 'Email',
21
+ type: 'string',
22
+ required: false,
23
+ default: {
24
+ '@if': {
25
+ exists: { '@path': '$.context.traits.email' },
26
+ then: { '@path': '$.context.traits.email' },
27
+ else: { '@path': '$.properties.email' }
28
+ }
29
+ }
30
+ },
31
+ phone: {
32
+ description: 'The phone number of the user to attach the device to.',
33
+ label: 'Phone',
34
+ type: 'string',
35
+ required: false,
36
+ default: {
37
+ '@if': {
38
+ exists: { '@path': '$.context.traits.phone' },
39
+ then: { '@path': '$.context.traits.phone' },
40
+ else: { '@path': '$.properties.phone' }
41
+ }
42
+ }
43
+ },
44
+ metadata: {
45
+ description: 'Metadata to attach to the device.',
46
+ label: 'Metadata',
47
+ type: 'object',
48
+ required: false,
49
+ defaultObjectUI: 'keyvalue'
50
+ },
51
+ include_page: {
52
+ description: 'Whether to include the page (url) in the attach request',
53
+ label: 'Include Page',
54
+ type: 'boolean',
55
+ required: false
56
+ }
57
+ },
58
+ perform(rupt, data) {
59
+ rupt.attach({
60
+ client_id: data.settings.client_id,
61
+ account: data.payload.account,
62
+ email: data.payload.email,
63
+ phone: data.payload.phone,
64
+ metadata: data.payload.metadata,
65
+ include_page: data.payload.include_page,
66
+ redirect_urls: {
67
+ new_account_url: data.settings.new_account_url,
68
+ success_url: data.settings.success_url,
69
+ suspended_url: data.settings.suspended_url,
70
+ logout_url: data.settings.logout_url
71
+ }
72
+ });
73
+ }
74
+ };
75
+ exports.default = attach;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/attach/index.ts"],"names":[],"mappings":";;AAKA,MAAM,MAAM,GAAqD;IAC/D,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,gCAAgC;IAC7C,mBAAmB,EAAE,eAAe;IACpC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,OAAO,EAAE;YACP,WAAW,EAAE,sCAAsC;YACnD,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,gDAAgD;YAC7D,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC7C,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;iBACxC;aACF;SACF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,uDAAuD;YACpE,KAAK,EAAE,OAAO;YACd,IAAI,EA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?: string;
5
+ metadata?: {
6
+ [k: string]: unknown;
7
+ };
8
+ include_page?: boolean;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=attach.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.types.js","sourceRoot":"","sources":["../../src/attach.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface Settings {
2
+ client_id: string;
3
+ new_account_url: string;
4
+ logout_url?: string;
5
+ success_url?: string;
6
+ suspended_url?: string;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from './generated-types';
3
+ import Rupt from './types';
4
+ declare global {
5
+ interface Window {
6
+ Rupt: Rupt;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Rupt>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.destination = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const actions_core_1 = require("@segment/actions-core");
6
+ const shim_1 = require("@segment/browser-destination-runtime/shim");
7
+ const attach_1 = tslib_1.__importDefault(require("./attach"));
8
+ const presets = [
9
+ {
10
+ name: 'Attach Device',
11
+ subscribe: "type = 'page'",
12
+ partnerAction: 'attach',
13
+ mapping: actions_core_1.defaultValues(attach_1.default.fields),
14
+ type: 'automatic'
15
+ }
16
+ ];
17
+ exports.destination = {
18
+ name: 'Rupt',
19
+ slug: 'actions-rupt',
20
+ mode: 'device',
21
+ presets,
22
+ settings: {
23
+ client_id: {
24
+ description: 'The API client id of your Rupt project.',
25
+ label: 'Client ID',
26
+ type: 'string',
27
+ required: true
28
+ },
29
+ new_account_url: {
30
+ description: 'A URL to redirect the user to if they want to stop account sharing and create a new account.',
31
+ label: 'New Account URL',
32
+ type: 'string',
33
+ required: true
34
+ },
35
+ logout_url: {
36
+ description: 'A URL to redirect the user to if they choose to logout or if they are removed by a verified owner.',
37
+ label: 'Logout URL',
38
+ type: 'string',
39
+ required: false
40
+ },
41
+ success_url: {
42
+ description: 'A URL to redirect the user to if they are successfully verified and are within the device limit.',
43
+ label: 'Success URL',
44
+ type: 'string',
45
+ required: false
46
+ },
47
+ suspended_url: {
48
+ description: 'A URL to redirect the user to if they are suspended.',
49
+ label: 'Suspended URL',
50
+ type: 'string',
51
+ required: false
52
+ }
53
+ },
54
+ initialize: async (_, deps) => {
55
+ try {
56
+ await deps.loadScript('https://cdn.rupt.dev/js/rupt.js');
57
+ await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'Rupt'), 500);
58
+ return window.Rupt;
59
+ }
60
+ catch (error) {
61
+ throw new Error('Failed to load Rupt. ' + error);
62
+ }
63
+ },
64
+ actions: {
65
+ attach: attach_1.default
66
+ }
67
+ };
68
+ exports.default = shim_1.browserDestination(exports.destination);
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,wDAA4E;AAC5E,oEAA8E;AAE9E,8DAA6B;AAU7B,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,eAAe;QAC1B,aAAa,EAAE,QAAQ;QACvB,OAAO,EAAE,4BAAa,CAAC,gBAAM,CAAC,MAAM,CAAC;QACrC,IAAI,EAAE,WAAW;KAClB;CACF,CAAA;AACY,QAAA,WAAW,GAAiD;IACvE,IAAI,EAAE,MAAM;IACZ,IAA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1
+ interface Redirects {
2
+ logout_url?: string;
3
+ new_account_url: string;
4
+ success_url?: string;
5
+ suspended_url?: string;
6
+ }
7
+ interface DetachConfig {
8
+ client_id: string;
9
+ secret?: string;
10
+ device: string;
11
+ account?: string;
12
+ domain?: string;
13
+ }
14
+ export interface LimitConfig {
15
+ overall_device_limit?: number;
16
+ people_limit?: number;
17
+ }
18
+ export interface AttachResponse {
19
+ success: boolean;
20
+ attached_devices: number;
21
+ device_id: string;
22
+ default_device_limit: number;
23
+ block_over_usage: boolean;
24
+ suspended?: boolean;
25
+ access: string;
26
+ identity: string;
27
+ }
28
+ export interface AttachConfig {
29
+ client_id: string;
30
+ secret?: string;
31
+ account: string;
32
+ email?: string;
33
+ phone?: string;
34
+ metadata?: object;
35
+ debug?: boolean;
36
+ identity?: string;
37
+ include_page?: boolean;
38
+ limit_config?: LimitConfig;
39
+ redirect_urls?: Redirects;
40
+ on_challenge?: () => boolean;
41
+ on_limit_exceeded?: () => void;
42
+ domain?: string;
43
+ }
44
+ declare type attach = ({ client_id, secret, account, email, phone, metadata, debug, identity, include_page, domain, limit_config, redirect_urls, on_challenge, on_limit_exceeded }: AttachConfig) => Promise<AttachResponse | null>;
45
+ declare type detach = ({ device, account, client_id, secret, domain }: DetachConfig) => Promise<any>;
46
+ export default interface Rupt {
47
+ attach: attach;
48
+ detach: detach;
49
+ }
50
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export interface Payload {
2
+ account: string;
3
+ email?: string;
4
+ phone?: string;
5
+ metadata?: {
6
+ [k: string]: unknown;
7
+ };
8
+ include_page?: boolean;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/attach/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
2
+ import { Payload } from 'src/attach.types';
3
+ import { Settings } from 'src/generated-types';
4
+ import Rupt from 'src/types';
5
+ declare const attach: BrowserActionDefinition<Settings, Rupt, Payload>;
6
+ export default attach;
@@ -0,0 +1,74 @@
1
+ const attach = {
2
+ title: 'Attach Device',
3
+ description: 'Attach a device to an account.',
4
+ defaultSubscription: 'type = "page"',
5
+ platform: 'web',
6
+ fields: {
7
+ account: {
8
+ description: 'The account to attach the device to.',
9
+ label: 'Account',
10
+ type: 'string',
11
+ required: true,
12
+ default: {
13
+ '@path': '$.userId'
14
+ }
15
+ },
16
+ email: {
17
+ description: 'The email of the user to attach the device to.',
18
+ label: 'Email',
19
+ type: 'string',
20
+ required: false,
21
+ default: {
22
+ '@if': {
23
+ exists: { '@path': '$.context.traits.email' },
24
+ then: { '@path': '$.context.traits.email' },
25
+ else: { '@path': '$.properties.email' }
26
+ }
27
+ }
28
+ },
29
+ phone: {
30
+ description: 'The phone number of the user to attach the device to.',
31
+ label: 'Phone',
32
+ type: 'string',
33
+ required: false,
34
+ default: {
35
+ '@if': {
36
+ exists: { '@path': '$.context.traits.phone' },
37
+ then: { '@path': '$.context.traits.phone' },
38
+ else: { '@path': '$.properties.phone' }
39
+ }
40
+ }
41
+ },
42
+ metadata: {
43
+ description: 'Metadata to attach to the device.',
44
+ label: 'Metadata',
45
+ type: 'object',
46
+ required: false,
47
+ defaultObjectUI: 'keyvalue'
48
+ },
49
+ include_page: {
50
+ description: 'Whether to include the page (url) in the attach request',
51
+ label: 'Include Page',
52
+ type: 'boolean',
53
+ required: false
54
+ }
55
+ },
56
+ perform(rupt, data) {
57
+ rupt.attach({
58
+ client_id: data.settings.client_id,
59
+ account: data.payload.account,
60
+ email: data.payload.email,
61
+ phone: data.payload.phone,
62
+ metadata: data.payload.metadata,
63
+ include_page: data.payload.include_page,
64
+ redirect_urls: {
65
+ new_account_url: data.settings.new_account_url,
66
+ success_url: data.settings.success_url,
67
+ suspended_url: data.settings.suspended_url,
68
+ logout_url: data.settings.logout_url
69
+ }
70
+ });
71
+ }
72
+ };
73
+ export default attach;
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/attach/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAqD;IAC/D,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,gCAAgC;IAC7C,mBAAmB,EAAE,eAAe;IACpC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,OAAO,EAAE;YACP,WAAW,EAAE,sCAAsC;YACnD,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,gDAAgD;YAC7D,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC7C,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;iBACxC;aACF;SACF;QACD,KAAK,EAAE;YACL,WAAW,EAAE,uDAAuD;YACpE,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC7C,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;oBAC3C,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;iBACxC;aACF;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,mCAAmC;YAChD,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,UAAU;SAC5B;QACD,YAAY,EAAE;YACZ,WAAW,EAAE,yDAAyD;YACtE,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;SAChB;KACF;IACD,OAAO,CAAC,IAAI,EAAE,IAAI;QAChB,IAAI,CAAC,MAAM,CAAC;YACV,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS;YAClC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;YAC/B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACvC,aAAa,EAAE;gBACb,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe;gBAC9C,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW;gBACtC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;gBAC1C,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU;aACrC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,9 @@
1
+ export interface Payload {
2
+ account: string;
3
+ email?: string;
4
+ phone?: string;
5
+ metadata?: {
6
+ [k: string]: unknown;
7
+ };
8
+ include_page?: boolean;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=attach.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attach.types.js","sourceRoot":"","sources":["../../src/attach.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export interface Settings {
2
+ client_id: string;
3
+ new_account_url: string;
4
+ logout_url?: string;
5
+ success_url?: string;
6
+ suspended_url?: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
2
+ import type { Settings } from './generated-types';
3
+ import Rupt from './types';
4
+ declare global {
5
+ interface Window {
6
+ Rupt: Rupt;
7
+ }
8
+ }
9
+ export declare const destination: BrowserDestinationDefinition<Settings, Rupt>;
10
+ declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
11
+ export default _default;
@@ -0,0 +1,65 @@
1
+ import { defaultValues } from '@segment/actions-core';
2
+ import { browserDestination } from '@segment/browser-destination-runtime/shim';
3
+ import attach from './attach';
4
+ const presets = [
5
+ {
6
+ name: 'Attach Device',
7
+ subscribe: "type = 'page'",
8
+ partnerAction: 'attach',
9
+ mapping: defaultValues(attach.fields),
10
+ type: 'automatic'
11
+ }
12
+ ];
13
+ export const destination = {
14
+ name: 'Rupt',
15
+ slug: 'actions-rupt',
16
+ mode: 'device',
17
+ presets,
18
+ settings: {
19
+ client_id: {
20
+ description: 'The API client id of your Rupt project.',
21
+ label: 'Client ID',
22
+ type: 'string',
23
+ required: true
24
+ },
25
+ new_account_url: {
26
+ description: 'A URL to redirect the user to if they want to stop account sharing and create a new account.',
27
+ label: 'New Account URL',
28
+ type: 'string',
29
+ required: true
30
+ },
31
+ logout_url: {
32
+ description: 'A URL to redirect the user to if they choose to logout or if they are removed by a verified owner.',
33
+ label: 'Logout URL',
34
+ type: 'string',
35
+ required: false
36
+ },
37
+ success_url: {
38
+ description: 'A URL to redirect the user to if they are successfully verified and are within the device limit.',
39
+ label: 'Success URL',
40
+ type: 'string',
41
+ required: false
42
+ },
43
+ suspended_url: {
44
+ description: 'A URL to redirect the user to if they are suspended.',
45
+ label: 'Suspended URL',
46
+ type: 'string',
47
+ required: false
48
+ }
49
+ },
50
+ initialize: async (_, deps) => {
51
+ try {
52
+ await deps.loadScript('https://cdn.rupt.dev/js/rupt.js');
53
+ await deps.resolveWhen(() => Object.prototype.hasOwnProperty.call(window, 'Rupt'), 500);
54
+ return window.Rupt;
55
+ }
56
+ catch (error) {
57
+ throw new Error('Failed to load Rupt. ' + error);
58
+ }
59
+ },
60
+ actions: {
61
+ attach
62
+ }
63
+ };
64
+ export default browserDestination(destination);
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAE9E,OAAO,MAAM,MAAM,UAAU,CAAA;AAU7B,MAAM,OAAO,GAAqC;IAChD;QACE,IAAI,EAAE,eAAe;QACrB,SAAS,EAAE,eAAe;QAC1B,aAAa,EAAE,QAAQ;QACvB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QACrC,IAAI,EAAE,WAAW;KAClB;CACF,CAAA;AACD,MAAM,CAAC,MAAM,WAAW,GAAiD;IACvE,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,QAAQ;IAEd,OAAO;IAEP,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,WAAW,EAAE,yCAAyC;YACtD,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,eAAe,EAAE;YACf,WAAW,EAAE,8FAA8F;YAC3G,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,WAAW,EAAE,oGAAoG;YACjH,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;QACD,WAAW,EAAE;YACX,WAAW,EAAE,kGAAkG;YAC/G,KAAK,EAAE,aAAa;YACpB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;QACD,aAAa,EAAE;YACb,WAAW,EAAE,sDAAsD;YACnE,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;KACF;IAED,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QAC5B,IAAI;YACF,MAAM,IAAI,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAA;YACxD,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;YACvF,OAAO,MAAM,CAAC,IAAI,CAAA;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAA;SACjD;IACH,CAAC;IACD,OAAO,EAAE;QACP,MAAM;KACP;CACF,CAAA;AAED,eAAe,kBAAkB,CAAC,WAAW,CAAC,CAAA"}
@@ -0,0 +1,50 @@
1
+ interface Redirects {
2
+ logout_url?: string;
3
+ new_account_url: string;
4
+ success_url?: string;
5
+ suspended_url?: string;
6
+ }
7
+ interface DetachConfig {
8
+ client_id: string;
9
+ secret?: string;
10
+ device: string;
11
+ account?: string;
12
+ domain?: string;
13
+ }
14
+ export interface LimitConfig {
15
+ overall_device_limit?: number;
16
+ people_limit?: number;
17
+ }
18
+ export interface AttachResponse {
19
+ success: boolean;
20
+ attached_devices: number;
21
+ device_id: string;
22
+ default_device_limit: number;
23
+ block_over_usage: boolean;
24
+ suspended?: boolean;
25
+ access: string;
26
+ identity: string;
27
+ }
28
+ export interface AttachConfig {
29
+ client_id: string;
30
+ secret?: string;
31
+ account: string;
32
+ email?: string;
33
+ phone?: string;
34
+ metadata?: object;
35
+ debug?: boolean;
36
+ identity?: string;
37
+ include_page?: boolean;
38
+ limit_config?: LimitConfig;
39
+ redirect_urls?: Redirects;
40
+ on_challenge?: () => boolean;
41
+ on_limit_exceeded?: () => void;
42
+ domain?: string;
43
+ }
44
+ declare type attach = ({ client_id, secret, account, email, phone, metadata, debug, identity, include_page, domain, limit_config, redirect_urls, on_challenge, on_limit_exceeded }: AttachConfig) => Promise<AttachResponse | null>;
45
+ declare type detach = ({ device, account, client_id, secret, domain }: DetachConfig) => Promise<any>;
46
+ export default interface Rupt {
47
+ attach: attach;
48
+ detach: detach;
49
+ }
50
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}