Skip to content

Commit

Permalink
Merge branch 'main' of github.com:transcend-io/airgap.js-types into c…
Browse files Browse the repository at this point in the history
…smccarthy/reserved-metadata
  • Loading branch information
csmccarthy committed Nov 8, 2023
2 parents 6aae6ca + c6880cb commit d0785b1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Transcend Inc.",
"name": "@transcend-io/airgap.js-types",
"description": "TypeScript types for airgap.js interoperability with custom consent UIs",
"version": "10.6.1",
"version": "10.7.2",
"homepage": "https://github.com/transcend-io/airgap.js-types",
"repository": {
"type": "git",
Expand Down
72 changes: 51 additions & 21 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import * as t from 'io-ts';
import { FixedLengthArray, valuesOf } from '@transcend-io/type-utils';

// local
import {
ConfigurablePurpose,
SpecialTrackingPurpose,
ViewState,
} from './enums';
import { SpecialTrackingPurpose, ViewState } from './enums';

/* eslint-disable max-lines */

Expand Down Expand Up @@ -320,7 +316,7 @@ export const TrackingPurposeDetails = t.intersection([
}),
t.partial({
/** Tracking type */
trackingType: valuesOf(ConfigurablePurpose),
trackingType: t.string,
/** Respected opt-out privacy signals */
optOutSignals: t.array(UserPrivacySignal),
}),
Expand Down Expand Up @@ -375,10 +371,15 @@ export const TrackingConsent = t.intersection([
*/
export type TrackingConsent = t.TypeOf<typeof TrackingConsent>;

export const TrackingConsentDetails = t.intersection([
export const TrackingConsentWithNulls = t.record(
t.string,
t.union([t.boolean, t.undefined, t.null]),
);
/** Type override */
export type TrackingConsentWithNulls = t.TypeOf<typeof TrackingConsent>;

const CoreTrackingConsentDetails = t.intersection([
t.type({
/** Tracking consent config */
purposes: TrackingConsent,
/**
* Was tracking consent confirmed by the user?
* If this is false, the consent was resolved from defaults & is not yet confirmed
Expand All @@ -399,30 +400,59 @@ export const TrackingConsentDetails = t.intersection([
}),
]);

/** Type override */
export type CoreTrackingConsentDetails = t.TypeOf<
typeof CoreTrackingConsentDetails
>;

export const TrackingConsentDetails = t.intersection([
CoreTrackingConsentDetails,
t.type({
/** Tracking consent config */
purposes: TrackingConsent,
}),
]);

/** Override types. */
export type TrackingConsentDetails = t.TypeOf<typeof TrackingConsentDetails>;

export const TrackingConsentOptionalData = t.partial({
/** Transparency Consent (TCF) String */
tcf: t.string,
/** US Privacy (USP) String */
usp: t.string,
/** Global Privacy Platform (GPP) String */
gpp: t.string,
/** Consent Manager View State */
viewState: valuesOf(ViewState),
/** Airgap Version */
airgapVersion: t.string,
});

export const FullTrackingConsentDetails = t.intersection([
TrackingConsentDetails,
t.partial({
/** Transparency Consent (TCF) String */
tcf: t.string,
/** US Privacy (USP) String */
usp: t.string,
/** Global Privacy Platform (GPP) String */
gpp: t.string,
/** Consent Manager View State */
viewState: valuesOf(ViewState),
/** Airgap Version */
airgapVersion: t.string,
}),
TrackingConsentOptionalData,
]);

/** Override types. */
export type FullTrackingConsentDetails = t.TypeOf<
typeof FullTrackingConsentDetails
>;

export const FullTrackingConsentDetailsWithNulls = t.intersection([
CoreTrackingConsentDetails,
TrackingConsentOptionalData,
t.type({
/** Tracking consent config */
purposes: TrackingConsentWithNulls,
}),
]);

/** Override types. */
export type FullTrackingConsentDetailsWithNulls = t.TypeOf<
typeof FullTrackingConsentDetailsWithNulls
>;

export const ConsentPreferencesBody = t.type({
/** token containing encrypted identifier */
token: t.string,
Expand Down
2 changes: 2 additions & 0 deletions src/enums/viewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export const InitialTranscendViewState = makeEnum({
NoticeAndDoNotSell: 'NoticeAndDoNotSell',
/* open a modal that allows for an explanation of do not sell/share, before opting out */
DoNotSellExplainer: 'DoNotSellExplainer',
/* open a modal that allows for complete options toggling */
CompleteOptionsToggles: 'CompleteOptionsToggles',
/* open a modal that shows a notice that the privacy policy has changed, without any prompt to change consent */
PrivacyPolicyNotice: 'PrivacyPolicyNotice',
/* expanded and showing full checkbox options */
Expand Down
2 changes: 2 additions & 0 deletions src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export type RequiredConsentManagerConfig = t.TypeOf<
export const OptionalConsentManagerConfig = t.partial({
/** The set of enabled languages - CSV of ConsentManagerLanguageKey */
languages: t.string,
/** The override value for the consent banner z-index */
uiZIndex: t.string,
});

/** type overload */
Expand Down

0 comments on commit d0785b1

Please sign in to comment.