Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<!--
## 🎫 Ticket

Link to the relevant ticket.
Link to the relevant ticket:
[LG-XXXXX](https://cm-jira.usa.gov/browse/LG-XXXXX)
-->

<!--
Expand Down
4 changes: 0 additions & 4 deletions app/components/form_link_component.html.erb

This file was deleted.

9 changes: 0 additions & 9 deletions app/components/form_link_component.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/components/form_link_component.ts

This file was deleted.

1 change: 0 additions & 1 deletion app/javascript/packages/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export { default as PageHeading } from './page-heading';
export { default as ProcessList } from './process-list/process-list';
export { default as ProcessListHeading } from './process-list/process-list-heading';
export { default as ProcessListItem } from './process-list/process-list-item';
export { default as ScrollIntoView } from './scroll-into-view';
export { default as SelectInput } from './select-input';
export { default as SpinnerDots } from './spinner-dots';
export { default as StatusPage } from './status-page';
Expand Down
28 changes: 0 additions & 28 deletions app/javascript/packages/components/scroll-into-view.spec.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions app/javascript/packages/components/scroll-into-view.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
} from './documents-step';
import type { ReviewIssuesStepValue } from './review-issues-step';

interface DocumentCaptureReviewIssuesProps
extends Omit<FormStepComponentProps<ReviewIssuesStepValue>, 'toPreviousStep'> {
interface DocumentCaptureReviewIssuesProps extends FormStepComponentProps<ReviewIssuesStepValue> {
isFailedDocType: boolean;
remainingAttempts: number;
captureHints: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function ReviewIssuesStep({
unknownFieldErrors = [],
onError = () => {},
registerField = () => undefined,
toPreviousStep = () => undefined,
remainingAttempts = Infinity,
isFailedResult = false,
isFailedDocType = false,
Expand Down Expand Up @@ -136,6 +137,7 @@ function ReviewIssuesStep({
errors={errors}
onChange={onChange}
onError={onError}
toPreviousStep={toPreviousStep}
hasDismissed
/>
);
Expand Down
22 changes: 0 additions & 22 deletions app/javascript/packages/form-link/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions app/javascript/packages/form-link/form-link-element.spec.ts

This file was deleted.

30 changes: 0 additions & 30 deletions app/javascript/packages/form-link/form-link-element.ts

This file was deleted.

5 changes: 0 additions & 5 deletions app/javascript/packages/form-link/package.json

This file was deleted.

9 changes: 4 additions & 5 deletions app/javascript/packages/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ interface I18nOptions {
strings?: Entries;
}

const hasOwn = (object: object, key: string): boolean =>
Object.prototype.hasOwnProperty.call(object, key);

/**
* Returns the pluralization object key corresponding to the given number.
*
Expand All @@ -33,7 +30,7 @@ const getPluralizationKey = (count: number): keyof PluralizedEntry =>
* @return Entry string or object.
*/
const getEntry = (strings: Entries, key: string): Entry =>
hasOwn(strings, key) ? strings[key] : key;
Object.hasOwn(strings, key) ? strings[key] : key;

/**
* Returns true if the given entry is a pluralization entry, or false otherwise.
Expand Down Expand Up @@ -83,7 +80,9 @@ function getString(entry: Entry, count?: number): string | string[] {
* @return String with variables substituted.
*/
export const replaceVariables = (string: string, variables: Variables): string =>
string.replace(/%{(\w+)}/g, (match, key) => (hasOwn(variables, key) ? variables[key] : match));
string.replace(/%{(\w+)}/g, (match, key) =>
Object.hasOwn(variables, key) ? variables[key] : match,
);

class I18n {
strings: Entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ function dig(object, keyPath) {
return result;
}

/**
* Given an array of key-value tuple pairs, returns the corresponding object form.
*
* @template V
*
* @param {[key: string, value: V][]} pairs
*
* @return {Record<string, V>}
*/
const fromPairs = (pairs) =>
pairs.reduce((result, [key, value]) => ({ ...result, [key]: value }), {});

/**
* Returns unique values from the given array.
*
Expand Down Expand Up @@ -237,7 +225,7 @@ class RailsI18nWebpackPlugin extends ExtractKeysWebpackPlugin {

const translations = await Promise.all(keys.map(getKeyTranslationPairs));
if (translations.length) {
return fromPairs(translations);
return Object.fromEntries(translations);
}
}

Expand All @@ -256,13 +244,12 @@ class RailsI18nWebpackPlugin extends ExtractKeysWebpackPlugin {
};

const localeAssets = await Promise.all(locales.map(getLocaleAssetsPairs));
return fromPairs(compact(localeAssets));
return Object.fromEntries(compact(localeAssets));
}
}

module.exports = RailsI18nWebpackPlugin;
module.exports.dig = dig;
module.exports.fromPairs = fromPairs;
module.exports.uniq = uniq;
module.exports.compact = compact;
module.exports.getKeyPath = getKeyPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const webpack = require('webpack');
const WebpackAssetsManifest = require('webpack-assets-manifest');
const RailsI18nWebpackPlugin = require('./rails-i18n-webpack-plugin.js');

const { dig, fromPairs, uniq, compact, getKeyPath, getKeyDomain, getKeyDomains } =
RailsI18nWebpackPlugin;
const { dig, uniq, compact, getKeyPath, getKeyDomain, getKeyDomains } = RailsI18nWebpackPlugin;

describe('RailsI18nWebpackPlugin', () => {
it('generates expected output', (done) => {
Expand Down Expand Up @@ -211,18 +210,6 @@ describe('dig', () => {
});
});

describe('fromPairs', () => {
it('returns pairs of key value in object form', () => {
const pairs = [
['a', 1],
['b', 2],
];
const result = fromPairs(pairs);

expect(result).to.deep.equal({ a: 1, b: 2 });
});
});

describe('uniq', () => {
it('returns unique values', () => {
const values = [1, 2, 2, 3];
Expand Down
48 changes: 46 additions & 2 deletions app/models/gpo_confirmation.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,63 @@
class GpoConfirmation < ApplicationRecord
self.table_name = 'usps_confirmations'

ENTRY_ATTRIBUTES = %i[otp address1 city state zipcode]
ENTRY_ATTRIBUTES.each do |attr|
define_method("entry_#{attr}".to_sym) do
entry[attr]
end
end

validates :entry, presence: true
validates :entry_otp, :entry_address1, :entry_city, :entry_state, :entry_zipcode, presence: true
validate :entry_zipcode_is_valid

ZIP_REGEX = /^(\d{5})[-+]?(\d+)?$/

# Store the pii as encrypted json
def entry=(entry_hash)
self[:entry] = encryptor.encrypt(entry_hash.to_json)
@entry = nil
self[:entry] = encryptor.encrypt(
entry_hash.
dup.
tap do |h|
h[:zipcode] = self.class.normalize_zipcode(h[:zipcode]) if h[:zipcode].present?
end.
to_json,
)
end

# Read the pii as a decrypted hash
def entry
JSON.parse(encryptor.decrypt(self[:entry]), symbolize_names: true)
@entry ||= JSON.parse(encryptor.decrypt(self[:entry]), symbolize_names: true)
end

def self.normalize_zipcode(zipcode)
_, zip, plus4 = ZIP_REGEX.match(zipcode&.gsub(/\s/, '')).to_a
if plus4&.length == 4
"#{zip}-#{plus4}"
else
zip
end
end

private

def encryptor
Encryption::Encryptors::BackgroundProofingArgEncryptor.new
end

def entry_zipcode_should_be_rejected_because_we_are_testing?
# We reserve a certain zipcode to be used to test this value in lower environments.
entry_zipcode.present? &&
entry_zipcode == IdentityConfig.store.invalid_gpo_confirmation_zipcode
end

def entry_zipcode_is_valid
normalized = self.class.normalize_zipcode(entry_zipcode)

if normalized.nil? || entry_zipcode_should_be_rejected_because_we_are_testing?
errors.add(:entry_zipcode, :invalid)
end
end
end
Loading