@globalpayments-private/gpds-pattern-web 0.0.0-stage → 0.1.0-pr.7.gdcb74cd

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 (97) hide show
  1. package/README.md +567 -2
  2. package/dist/cjs/control-strategy-DhhYTbse.js +113 -0
  3. package/dist/cjs/gpds-pattern-web.cjs.js +24 -0
  4. package/dist/cjs/index-Dzm6P89U.js +1565 -0
  5. package/dist/cjs/index.cjs.js +180 -0
  6. package/dist/cjs/loader.cjs.js +12 -0
  7. package/dist/cjs/uds-pattern-login-card_2.cjs.entry.js +1662 -0
  8. package/dist/collection/collection-manifest.json +14 -0
  9. package/dist/collection/components/uds-pattern-login-card/slimmers/identity-memory.slimmer.js +63 -0
  10. package/dist/collection/components/uds-pattern-login-card/slimmers/login-workflow.slimmer.js +357 -0
  11. package/dist/collection/components/uds-pattern-login-card/slimmers/renderers/login-card-renderer.js +100 -0
  12. package/dist/collection/components/uds-pattern-login-card/slimmers/renderers/login-field-renderer.js +129 -0
  13. package/dist/collection/components/uds-pattern-login-card/slimmers/renderers/login-step-renderer.js +192 -0
  14. package/dist/collection/components/uds-pattern-login-card/slimmers/resend-throttle.slimmer.js +65 -0
  15. package/dist/collection/components/uds-pattern-login-card/uds-pattern-login-card.css +154 -0
  16. package/dist/collection/components/uds-pattern-login-card/uds-pattern-login-card.js +508 -0
  17. package/dist/collection/components/uds-pattern-login-card/validation/login-validation-rules.js +86 -0
  18. package/dist/collection/components/uds-pattern-login-card/view-model/login-card-handlers.js +1 -0
  19. package/dist/collection/components/uds-pattern-login-card/view-model/login-step.view-model.js +138 -0
  20. package/dist/collection/components/uds-pattern-login-page/uds-pattern-login-page.css +37 -0
  21. package/dist/collection/components/uds-pattern-login-page/uds-pattern-login-page.js +97 -0
  22. package/dist/collection/index.js +5 -0
  23. package/dist/collection/providers/auth-provider.js +28 -0
  24. package/dist/collection/providers/control-strategy.js +21 -0
  25. package/dist/collection/providers/login-config.js +4 -0
  26. package/dist/collection/providers/memory-auth-provider.js +133 -0
  27. package/dist/collection/providers/parse-auth-result.js +135 -0
  28. package/dist/collection/slimmer/common/log.js +14 -0
  29. package/dist/collection/slimmer/common/symbols.js +10 -0
  30. package/dist/collection/slimmer/common/types.js +2 -0
  31. package/dist/collection/slimmer/decorators/inject-slimmer.js +73 -0
  32. package/dist/collection/slimmer/decorators/map-to-component-field.js +41 -0
  33. package/dist/collection/slimmer/decorators/map-to-component-method.js +33 -0
  34. package/dist/collection/slimmer/decorators/slimmer.js +10 -0
  35. package/dist/collection/slimmer/index.js +5 -0
  36. package/dist/collection/utils/labels.js +81 -0
  37. package/dist/collection/utils/types.js +1 -0
  38. package/dist/components/index.d.ts +35 -0
  39. package/dist/components/index.js +1 -0
  40. package/dist/components/p-DOrg55po.js +1 -0
  41. package/dist/components/p-_G8A9gg0.js +1 -0
  42. package/dist/components/uds-pattern-login-card.d.ts +11 -0
  43. package/dist/components/uds-pattern-login-card.js +1 -0
  44. package/dist/components/uds-pattern-login-page.d.ts +11 -0
  45. package/dist/components/uds-pattern-login-page.js +1 -0
  46. package/dist/docs.d.ts +480 -0
  47. package/dist/docs.json +549 -0
  48. package/dist/esm/control-strategy-DOrg55po.js +105 -0
  49. package/dist/esm/gpds-pattern-web.js +20 -0
  50. package/dist/esm/index-DsXlLyGj.js +1537 -0
  51. package/dist/esm/index.js +170 -0
  52. package/dist/esm/loader.js +10 -0
  53. package/dist/esm/uds-pattern-login-card_2.entry.js +1659 -0
  54. package/dist/gpds-pattern-web/gpds-pattern-web.css +1 -0
  55. package/dist/gpds-pattern-web/gpds-pattern-web.esm.js +1 -0
  56. package/dist/gpds-pattern-web/index.esm.js +1 -0
  57. package/dist/gpds-pattern-web/p-2c97d2da.entry.js +1 -0
  58. package/dist/gpds-pattern-web/p-DOrg55po.js +1 -0
  59. package/dist/gpds-pattern-web/p-DsXlLyGj.js +3 -0
  60. package/dist/index.cjs.js +1 -0
  61. package/dist/index.js +1 -0
  62. package/dist/types/components/uds-pattern-login-card/slimmers/identity-memory.slimmer.d.ts +21 -0
  63. package/dist/types/components/uds-pattern-login-card/slimmers/login-workflow.slimmer.d.ts +100 -0
  64. package/dist/types/components/uds-pattern-login-card/slimmers/renderers/login-card-renderer.d.ts +44 -0
  65. package/dist/types/components/uds-pattern-login-card/slimmers/renderers/login-field-renderer.d.ts +91 -0
  66. package/dist/types/components/uds-pattern-login-card/slimmers/renderers/login-step-renderer.d.ts +40 -0
  67. package/dist/types/components/uds-pattern-login-card/slimmers/resend-throttle.slimmer.d.ts +21 -0
  68. package/dist/types/components/uds-pattern-login-card/uds-pattern-login-card.d.ts +134 -0
  69. package/dist/types/components/uds-pattern-login-card/validation/login-validation-rules.d.ts +72 -0
  70. package/dist/types/components/uds-pattern-login-card/view-model/login-card-handlers.d.ts +21 -0
  71. package/dist/types/components/uds-pattern-login-card/view-model/login-step.view-model.d.ts +96 -0
  72. package/dist/types/components/uds-pattern-login-page/uds-pattern-login-page.d.ts +21 -0
  73. package/dist/types/components.d.ts +327 -0
  74. package/dist/types/index.d.ts +10 -0
  75. package/dist/types/providers/auth-provider.d.ts +168 -0
  76. package/dist/types/providers/control-strategy.d.ts +144 -0
  77. package/dist/types/providers/login-config.d.ts +52 -0
  78. package/dist/types/providers/memory-auth-provider.d.ts +37 -0
  79. package/dist/types/providers/parse-auth-result.d.ts +8 -0
  80. package/dist/types/slimmer/common/log.d.ts +8 -0
  81. package/dist/types/slimmer/common/symbols.d.ts +10 -0
  82. package/dist/types/slimmer/common/types.d.ts +30 -0
  83. package/dist/types/slimmer/decorators/inject-slimmer.d.ts +24 -0
  84. package/dist/types/slimmer/decorators/map-to-component-field.d.ts +16 -0
  85. package/dist/types/slimmer/decorators/map-to-component-method.d.ts +11 -0
  86. package/dist/types/slimmer/decorators/slimmer.d.ts +10 -0
  87. package/dist/types/slimmer/index.d.ts +6 -0
  88. package/dist/types/stencil-public-runtime.d.ts +1879 -0
  89. package/dist/types/utils/labels.d.ts +13 -0
  90. package/dist/types/utils/types.d.ts +106 -0
  91. package/dist/types/vega.d.ts +11 -0
  92. package/loader/cdn.js +1 -0
  93. package/loader/index.cjs.js +1 -0
  94. package/loader/index.d.ts +24 -0
  95. package/loader/index.es2017.js +1 -0
  96. package/loader/index.js +2 -0
  97. package/package.json +82 -4
@@ -0,0 +1,180 @@
1
+ 'use strict';
2
+
3
+ var controlStrategy = require('./control-strategy-DhhYTbse.js');
4
+
5
+ /**
6
+ * Provider contracts for the GP pattern library.
7
+ *
8
+ * A pattern owns the *workflow* — which step comes next, what is in flight,
9
+ * what the user is told when something fails. It owns no SDK code and knows no
10
+ * identity platform. The seam between the two is a Provider contract: the
11
+ * consumer brings their own backend SDK (Okta, Auth0, Cognito, Ping, GCP API
12
+ * Gateway, Azure APIM, …) and writes a thin adapter against the interface
13
+ * below.
14
+ *
15
+ * See `docs/adr/0002-provider-driven-patterns.md` for why the workflow lives
16
+ * inside the pattern rather than in the host application.
17
+ */
18
+ /**
19
+ * Identity helper that gives adapter authors type inference and a single place
20
+ * to add shared behaviour later (telemetry, retry, logging) without changing
21
+ * every call site.
22
+ *
23
+ * ```ts
24
+ * const auth = createAuthProvider({
25
+ * signIn: ({ identifier, password }) => oktaSdk.authn(identifier, password),
26
+ * verifyOtp: ({ code }) => oktaSdk.verifyFactor(code),
27
+ * });
28
+ * ```
29
+ */
30
+ function createAuthProvider(provider) {
31
+ return provider;
32
+ }
33
+
34
+ const DEFAULT_USER = {
35
+ identifier: 'ada@example.com',
36
+ password: 'correct-horse',
37
+ mfaMethods: [
38
+ { id: 'app', label: 'Authenticator app', description: 'Use the code from your authenticator app' },
39
+ { id: 'sms', label: 'Text message', description: 'Ending in ••3312' },
40
+ ],
41
+ otpCode: '555555',
42
+ };
43
+ /**
44
+ * An in-memory reference implementation of {@link UdsAuthProvider}.
45
+ *
46
+ * It exists so the demo harness and the test suite can drive the *real*
47
+ * workflow — identifier → password → MFA choice → OTP → success, plus the
48
+ * recovery, lockout and sign-up branches — without a network or an identity
49
+ * platform. It is also the worked example adapter authors copy from.
50
+ *
51
+ * Not intended for production use: it compares passwords in plain text.
52
+ */
53
+ function createMemoryAuthProvider(options = {}) {
54
+ const users = options.users ?? [DEFAULT_USER];
55
+ const maxAttempts = options.maxAttempts ?? 3;
56
+ const resendAfterMs = options.resendAfterMs ?? 30000;
57
+ const caps = {
58
+ signUp: true,
59
+ requestPasswordReset: true,
60
+ requestUsernameReminder: true,
61
+ resendOtp: true,
62
+ ...options.capabilities,
63
+ };
64
+ // Server-side state of the in-flight attempt.
65
+ let pending;
66
+ let failures = 0;
67
+ let locked = false;
68
+ const find = (identifier) => users.find(u => u.identifier.toLowerCase() === identifier.trim().toLowerCase());
69
+ const afterPassword = (user) => {
70
+ failures = 0;
71
+ if (user.mustResetPassword) {
72
+ return { status: 'password_reset_required' };
73
+ }
74
+ if (user.mfaMethods?.length) {
75
+ return { status: 'mfa_required', methods: user.mfaMethods };
76
+ }
77
+ return { status: 'success', session: { identifier: user.identifier } };
78
+ };
79
+ const provider = {
80
+ async signIn({ identifier, password }) {
81
+ if (locked) {
82
+ return { status: 'locked' };
83
+ }
84
+ const user = find(identifier);
85
+ if (!user) {
86
+ return { status: 'error', code: 'account_not_found' };
87
+ }
88
+ pending = user;
89
+ // Identifier-first: no password supplied yet.
90
+ if (password === undefined) {
91
+ return { status: 'password_required' };
92
+ }
93
+ return provider.verifyPassword({ identifier, password });
94
+ },
95
+ async verifyPassword({ password }) {
96
+ if (locked) {
97
+ return { status: 'locked' };
98
+ }
99
+ if (!pending) {
100
+ return { status: 'error', code: 'unknown' };
101
+ }
102
+ if (password !== pending.password) {
103
+ failures += 1;
104
+ if (failures >= maxAttempts) {
105
+ locked = true;
106
+ return { status: 'locked', unlockAfterMs: 15 * 60000 };
107
+ }
108
+ return { status: 'error', code: 'invalid_credentials' };
109
+ }
110
+ return afterPassword(pending);
111
+ },
112
+ async selectMfaMethod({ methodId }) {
113
+ const method = pending?.mfaMethods?.find(m => m.id === methodId);
114
+ return { status: 'otp_required', method, codeLength: 6, resendAfterMs };
115
+ },
116
+ async verifyOtp({ code }) {
117
+ if (code !== (pending?.otpCode ?? DEFAULT_USER.otpCode)) {
118
+ failures += 1;
119
+ if (failures >= maxAttempts) {
120
+ locked = true;
121
+ return { status: 'locked' };
122
+ }
123
+ return { status: 'error', code: 'invalid_code' };
124
+ }
125
+ failures = 0;
126
+ return { status: 'success', session: { identifier: pending?.identifier } };
127
+ },
128
+ async resetPassword({ password }) {
129
+ if (password.length < 8) {
130
+ return { status: 'error', code: 'password_policy' };
131
+ }
132
+ if (pending) {
133
+ pending.password = password;
134
+ pending.mustResetPassword = false;
135
+ }
136
+ return { status: 'success', session: { identifier: pending?.identifier } };
137
+ },
138
+ };
139
+ if (caps.resendOtp) {
140
+ provider.resendOtp = async () => ({ status: 'otp_required', codeLength: 6, resendAfterMs });
141
+ }
142
+ if (caps.requestPasswordReset) {
143
+ provider.requestPasswordReset = async ({ identifier }) => {
144
+ const user = find(identifier);
145
+ return user
146
+ ? { status: 'reset_link_sent', destination: user.identifier }
147
+ : { status: 'error', code: 'account_not_found' };
148
+ };
149
+ }
150
+ if (caps.requestUsernameReminder) {
151
+ provider.requestUsernameReminder = async ({ email }) => ({ status: 'username_sent', destination: email });
152
+ }
153
+ if (caps.signUp) {
154
+ provider.signUp = async ({ firstName, lastName, identifier }) => {
155
+ if (find(identifier)) {
156
+ return { status: 'error', code: 'account_exists' };
157
+ }
158
+ const user = { identifier, password: '', otpCode: DEFAULT_USER.otpCode };
159
+ users.push(user);
160
+ pending = user;
161
+ return { status: 'success', session: { identifier, firstName, lastName } };
162
+ };
163
+ }
164
+ return createAuthProvider(provider);
165
+ }
166
+
167
+ /** Identity helper giving a config literal its types without an annotation. */
168
+ function createLoginConfig(config) {
169
+ return config;
170
+ }
171
+
172
+ exports.DEFAULT_LOGIN_LABELS = controlStrategy.DEFAULT_LOGIN_LABELS;
173
+ exports.createControlStrategy = controlStrategy.createControlStrategy;
174
+ exports.fail = controlStrategy.fail;
175
+ exports.formatLabel = controlStrategy.formatLabel;
176
+ exports.goTo = controlStrategy.goTo;
177
+ exports.stay = controlStrategy.stay;
178
+ exports.createAuthProvider = createAuthProvider;
179
+ exports.createLoginConfig = createLoginConfig;
180
+ exports.createMemoryAuthProvider = createMemoryAuthProvider;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-Dzm6P89U.js');
4
+
5
+ const defineCustomElements = async (win, options) => {
6
+ if (typeof window === 'undefined') return undefined;
7
+ await index.globalScripts();
8
+ return index.bootstrapLazy([["uds-pattern-login-card_2.cjs",[[257,"uds-pattern-login-card",{"config":[1],"initialStep":[1,"initial-step"],"identifier":[1],"otpLength":[2,"otp-length"],"rememberStorageKey":[1,"remember-storage-key"],"showHelpFooter":[4,"show-help-footer"],"step":[32],"busy":[32],"errorText":[32],"methods":[32],"otpMethodLabel":[32],"destination":[32],"unlockMinutes":[32],"resendAt":[32],"nowTick":[32],"values":[32],"reset":[64]}],[257,"uds-pattern-login-page",{"logoSrc":[1,"logo-src"],"logoAlt":[1,"logo-alt"],"logoHref":[1,"logo-href"]}]]]], options);
9
+ };
10
+
11
+ exports.setNonce = index.setNonce;
12
+ exports.defineCustomElements = defineCustomElements;